Page 1 of 1

i want my model walk!!

Posted: Wed Jan 04, 2006 10:12 pm
by byelan74
i want to use "createFlyStraightAnimator" to move my model in my direction.

i have direction but i cant make it move.

my direction is
core::vector3df direction( sin( ( Mynode->getRotation().Y + 180) * core:: PI/180.0f ), 0, cos( ( Mynode->getRotation().Y + 180 ) * core:: PI/180.0f ) );
how can i make it walk.

Posted: Wed Jan 04, 2006 10:59 pm
by bitplane
http://irrlicht.sourceforge.net/docu/cl ... nager.html

Code: Select all

virtual ISceneNodeAnimator * 	createFlyStraightAnimator (const core::vector3df &startPoint, const core::vector3df &endPoint, u32 timeForWay, bool loop=false)
the key thing about FlyStraightAnimators is that they fly straight. if you want it to change direction as you rotate you're better off just using setPosition(getPosition()*direction*time)

Posted: Wed Jan 04, 2006 11:36 pm
by byelan74
Thanks....

But set position doesnt smooth.

how can i make it smooth.

Posted: Wed Jan 04, 2006 11:40 pm
by JP
To make it smooth with setPosition you have to update the position a little bit each frame, so you can use d = s * t and calculate the time since the last frame, and then multiply that by the speed you want the model to walk at, and then that gives you the distance the model should be moved in that frame. The overall effect will be of smooth movement.

Posted: Wed Jan 04, 2006 11:52 pm
by byelan74
i'm sorry that i stupid :oops: .

but......How can i calculate the time since the lanst frame.

Posted: Thu Jan 05, 2006 12:19 am
by Conquistador
Look up ITimer.

Code: Select all

ITimer* Timer = Device->getTimer();
u32 lastTime = Timer->getRealTime();
u32 timeSinceLastFrame = 0;

while (Device->run())
{
   timeSinceLastFrame = lastTime - Timer->getRealTime();
   lastTime = Timer->getRealTime();
}
It should go something like that.

Posted: Thu Jan 05, 2006 2:18 pm
by byelan74
Thanks for everyone