Smooth enemy movement

Get help using Construct 2

Post » Wed Aug 15, 2012 10:29 am

Hello guys I have enemy what I am doing is that every 8 seconds this enemy moves forward by 4 pixels in current angle. So I have like:

system every 8 seconds
   enemy move forward 4 pixels


The problem is that I want my enemy to move smoothly. I mean right now the movement is kinda jerky. It looks more like it jumps to the new position. But I want it move smoothly by those 4 pixels . How to do that? thank youMichal112012-08-15 10:32:33
B
8
S
2
Posts: 45
Reputation: 1,168

Post » Wed Aug 15, 2012 10:59 am

Look up the Lerp() function.
B
36
S
10
G
6
Posts: 948
Reputation: 11,101

Post » Wed Aug 15, 2012 12:02 pm

make sure you use delta time (dt) to make your game framerate independent

Here's a link to manual
http://www.scirra.com/tutorials/67/delta-time-and-framerate-independence
ImageImageImageImage
B
140
S
58
G
36
Posts: 2,547
Reputation: 31,170

Post » Wed Aug 15, 2012 12:37 pm

Rory: yeah I am trying to use it but no luck :/

shinkan: yep normally I use it. Since this is just testing for me I did not in this case.
B
8
S
2
Posts: 45
Reputation: 1,168

Post » Wed Aug 15, 2012 12:52 pm

if you can use external plugins use moveto behavior

if you can't, well you're stuck with lerp
B
81
S
50
G
10
Posts: 555
Reputation: 13,009

Post » Wed Aug 15, 2012 1:26 pm

I would like to use lerp as I want to learn it without plugins but I dont understands how lerp will help in this case. Could you be more specific how should I use lerp in this situation
B
8
S
2
Posts: 45
Reputation: 1,168

Post » Wed Aug 15, 2012 4:28 pm

Here's one way to do it:
stepMovement.capx (r99)
B
27
S
8
G
8
Posts: 903
Reputation: 8,452

Post » Wed Aug 15, 2012 8:40 pm

[QUOTE=Nimtrix] Here's one way to do it:
stepMovement.capx (r99)[/QUOTE]

Thank you I have to study it more because it seems complicated in this example.

However I tried to understand lerp by my way, I think I finally understand little bit why is it useful. But still no luck.

Now I have every 8 second, enemy1 move forward and I Put in: lerp(enemy1.Y,enemy1.Y+50,0.8*dt)

but the movement is still not smooth and it still looks like it is jumping to that position :/ Michal112012-08-15 20:41:37
B
8
S
2
Posts: 45
Reputation: 1,168

Post » Wed Aug 15, 2012 11:05 pm

lerp is a function to make easy for you search and walk a path between two points.

if you want a smoothly movement, you'll need acceleration and deceleration, or it will jump between pixels with the instantly maximum speed.

Another thing, if you set your project to use pixel rounding, it will keep the old position then jump one pixel when the object reach this pixel distance, so, it can show an animation not much smoothly.

If it's your case, just use linear Sampling.
ImageImageImageImageImageImage
B
93
S
20
G
12
Posts: 1,212
Reputation: 18,482

Post » Wed Aug 15, 2012 11:36 pm

Thank you but could some of you be that specific and actually past a code example here? just take mine and reedit it. I am not programmer so I am totally lost :) sorry for so many questions.
B
8
S
2
Posts: 45
Reputation: 1,168

Next

Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 3 guests