Movement curve

Posted By: bstudio

Movement curve - 10/09/08 13:09

So...

To state an example:
I have a player and an enemy. The enemy needs to move towards the player, but I don't want to do this in a straight line. So I want his "path" to curve a bit (illustrated by the following picture)



The black line is what I want. I looked at some tutorials about interpolation, but couldn't really figure it out. Some psudo code or something to get me started would be greatly appreciated smile

b-studio
Posted By: Michael_Schwarz

Re: Movement curve - 10/09/08 13:54

well, you will need to work with cos() and sin() but don't ask me any further. I'm no maths mayor wink

maybe just try around a bit, or wait until someone comes by who didnt fail math laugh
Posted By: Vadim647

Re: Movement curve - 10/09/08 14:46

let's think about it...
Basic is (x is movement towards direction, y is horizontal offset)
x = position
y = cos(position/distance*180)
Usage of vec_rotate can do other things.
Posted By: Joozey

Re: Movement curve - 10/09/08 16:53

I would let the enemy face the player, then add a slight deviation off from the player (doesn't need to be the facing direction, only the movement direction, so he sort of strives sideways), and shrink this deviation to 0 when the enemy approaches the player.
Posted By: bstudio

Re: Movement curve - 10/10/08 07:29

Thanks for your help, I'll check if I can make it work smile
© 2024 lite-C Forums