Creating Smooth Movement

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
abrams.b.a
Posts: 13
Joined: Tue Jul 19, 2011 10:17 am
Location: Eindhoven, NL

Creating Smooth Movement

Post by abrams.b.a »

Hello Everybody,

Thanks for taking the time to read this. I'm a bit new to game programming in general, though I've dabbled in it before but not very seriously.
I just have a question more related as to how you would do something, not so much to solve it for me.

When I move a node between lets say point A(0,0,0) and point B(456,0,38), I'm wondering how to make it seem like it's smoothly tweening between positions and not rigidly move. I'm making a system sort of a long the lines of Diablo 2 where you click and the character moves there.

My first guess is to implement (in psuedo code)

Code: Select all

 
If ( the character is not currently moving )
{
     set a start position
     set an eind position
     calculate the time it should take
     create a scene animator
}
Else ( if he already has a path )
{
     Delete the old animator
     set a new start position
     set a new eind position
     calculate the time
     Create a scene node animator
}
 
At each click I would get the nodes current position and set a path to the new location. If he clicks again mid path, I could delete the current path, and reset the locations and create a new one.
I'm just wondering from the more experienced people if this is a good option, or if otherwise how have you handled it?

Edit: I also saw the smooth movement in the FAQ, but it's not really what I'm looking for.
Radikalizm
Posts: 1215
Joined: Tue Jan 09, 2007 7:03 pm
Location: Leuven, Belgium

Re: Creating Smooth Movement

Post by Radikalizm »

Check out the follow spline animator, I believe this will give the results you want (if I understand correctly)

http://irrlicht.sourceforge.net/docu/cl ... 1054a0c3ba

You can feed it a set of points it should follow and the function will create a spline based off of these points which your node can then follow
abrams.b.a
Posts: 13
Joined: Tue Jul 19, 2011 10:17 am
Location: Eindhoven, NL

Re: Creating Smooth Movement

Post by abrams.b.a »

Radikalizm wrote:Check out the follow spline animator, I believe this will give the results you want (if I understand correctly)

http://irrlicht.sourceforge.net/docu/cl ... 1054a0c3ba

You can feed it a set of points it should follow and the function will create a spline based off of these points which your node can then follow
Oh cool, This seems to be quite handy. I'll give this a shot and see what I come up with, thank you.
stefbuet
Competition winner
Posts: 495
Joined: Sun Dec 09, 2007 4:13 pm
Location: france

Re: Creating Smooth Movement

Post by stefbuet »

Or you could use this small lib to create smooth transitions, with plenty of different equations available.
http://code.google.com/p/cpptweener/
CuteAlien wrote:coders are well-known creatures of the night
Post Reply