Stupid question about control model

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
byelan74
Posts: 28
Joined: Sat Dec 24, 2005 11:29 am

Stupid question about control model

Post by byelan74 »

I want model walk by pressed W, A, S, D key. i can animate model, but i cant make it move by pressed a key. i have walkthrough all of tutorial and i serch in the forum, but i still have a problem.

i'm not good in English. Sorry..... :oops:

Help me Please... :?:
AndreOdendaal
Posts: 16
Joined: Tue Dec 27, 2005 10:13 am
Location: Johannesburg, South Africa

Post by AndreOdendaal »

You'll need an IEventReceiver to capture the keyboard input.

Cast your object as IAnimatedMeshSceneNode and use AnimationSpeed to make the model walk. (IE set the speed to 0 by default and when the user presses a key set the AnimationSpeed to whatever it needs to be.).

Lastly you can use SetFrameLoop to manage what of the mesh is rendered.

Then you just need to update the position and rotation of the object depending on the speed you want the model to walk and its rotation
byelan74
Posts: 28
Joined: Sat Dec 24, 2005 11:29 am

Post by byelan74 »

Please code for me please...... :oops:
boboS
Posts: 188
Joined: Tue Oct 18, 2005 6:36 pm
Location: Romania

Post by boboS »

As your ship is going down
ll stand by and watch you drown
byelan74
Posts: 28
Joined: Sat Dec 24, 2005 11:29 am

Post by byelan74 »

I can set a key but i cant code in that case.
i have no idea to make it walk. :roll:
switch(event.KeyInput.Key)
{
case KEY_KEY_W:
{
****** I dont know, how to code in this ******
}
XFactor
Posts: 39
Joined: Fri Jun 03, 2005 5:30 am

Post by XFactor »

case KEY_KEY_W:
{
vector3df moveForward = yourNodeName->getAbsolutePosition();
moveForward.Y += 50; // Work with this part to find the correct direction
yourNodeName->setPosition(moveForward);
}
IRRLICHT ROCKS!!!!
byelan74
Posts: 28
Joined: Sat Dec 24, 2005 11:29 am

Post by byelan74 »

Thanks XFactor. that code is worked. but it not smooth.

are there any way to make it smooth.

thanks everybody.
razmott

Post by razmott »

Hi !

I think you should use an Animator like this:

case KEY_KEY_W:
{
vector3df moveForward = yourNodeName->getAbsolutePosition();
moveForward.Y += 50;
ISceneNodeAnimator* runto = SceneManager->createFlyStraightAnimator(
yourNodeName->getAbsolutePosition(), moveForward, time, 0);
yourNodeName->addAnimator(runto);
runto->drop();
}

PS : "time" is a constant which will define your model speed.
boboS
Posts: 188
Joined: Tue Oct 18, 2005 6:36 pm
Location: Romania

Post by boboS »

Look at the wiki page and search for bool keys[].

If you use array of booleans to tell if a key is pressed, movement should be smother.
As your ship is going down
ll stand by and watch you drown
Post Reply