Back and forth behavior

Forum for plugin, effect and behavior programmers. Please use the Help & Support forum for help using Construct.

Post » Thu Nov 05, 2009 8:13 am

Please do not yell at me, this is my first project.

I am trying to give a boat behavior on a 2d plane.

It does not turn, it does not go up or down, I just want it to go left and right.

Does anyone know how I can do this?
B
2
G
3
Posts: 24
Reputation: 898

Post » Thu Nov 05, 2009 9:15 am

Have you looked at the sin behavior? Or did you want more of a ferry-across-the-river type movement?
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,564

Post » Fri Nov 06, 2009 6:56 am

I did look at Sin, it is what im using to make the boat bob in the water. It should be left and right, like the paddle in breakout or arkanoid.
B
2
G
3
Posts: 24
Reputation: 898

Post » Fri Nov 06, 2009 7:00 am

You can use the 8-direction behavior for this. It lets you allow only up/down movement or only left/right movement in the "Directions" setting. You can also turn off rotation as well by setting "Rotation" to none.
Moderator
B
98
S
37
G
19
Posts: 1,584
Reputation: 17,817

Post » Fri Nov 06, 2009 7:31 pm

Perfect, Thanks!
B
2
G
3
Posts: 24
Reputation: 898

Post » Fri Nov 06, 2009 9:11 pm

you can easily program this with events:
key left is down> set .x to .x-1*(timedelta*60)
key right is down> set .x to .x+1*(timedelta*60)
B
25
S
3
G
6
Posts: 1,197
Reputation: 5,620

Post » Fri Nov 06, 2009 11:34 pm

Since it's a boat you might not want to use jerky movements.

key left is down>
set .x to lerp(.x,0,1-0.5^timedelta)
key right is down>
set .x to lerp(.x,displaywidth, 1-0.5^timedelta)
Image Image
B
161
S
48
G
90
Posts: 7,350
Reputation: 66,755

Post » Sat Nov 07, 2009 12:35 am

Thanks for everyones help. I got it exactly how I wanted it with the 8 way directional, and then removing the rotate and up and down.

This is my first game and I know I'm going to need a lot of help so thank you in advance.
B
2
G
3
Posts: 24
Reputation: 898


Return to Construct engineering

Who is online

Users browsing this forum: No registered users and 0 guests