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.
byelan74
Posts: 28 Joined: Sat Dec 24, 2005 11:29 am
Post
by byelan74 » Wed Jan 04, 2006 10:12 pm
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.
bitplane
Admin
Posts: 3204 Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:
Post
by bitplane » Wed Jan 04, 2006 10:59 pm
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)
byelan74
Posts: 28 Joined: Sat Dec 24, 2005 11:29 am
Post
by byelan74 » Wed Jan 04, 2006 11:36 pm
Thanks....
But set position doesnt smooth.
how can i make it smooth.
JP
Posts: 4526 Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:
Post
by JP » Wed Jan 04, 2006 11:40 pm
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.
byelan74
Posts: 28 Joined: Sat Dec 24, 2005 11:29 am
Post
by byelan74 » Wed Jan 04, 2006 11:52 pm
i'm sorry that i stupid
.
but......How can i calculate the time since the lanst frame.
Conquistador
Posts: 340 Joined: Wed Sep 28, 2005 4:38 pm
Location: Canada, Eh!
Post
by Conquistador » Thu Jan 05, 2006 12:19 am
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.
byelan74
Posts: 28 Joined: Sat Dec 24, 2005 11:29 am
Post
by byelan74 » Thu Jan 05, 2006 2:18 pm
Thanks for everyone