Sinus/Cosinus for movement
Posted: Wed Aug 08, 2007 8:07 pm
I wanted to make a model move freely in 360°, but when changing direction (+/-45°) the directions change a little. As an example on O° it gets up, +45° and back, the movement goes up with a little to the right.
In class MyEventReceiver : public IEventReceiver:
In update()
What can the problem be?
myPos is a struct with floats.
In class MyEventReceiver : public IEventReceiver:
Code: Select all
case KEY_KEY_Q:
player->angle-=45;
break;
case KEY_KEY_D:
player->angle+=45;
break;
Code: Select all
myPos.x += cos(angle) /10.;
myPos.z += sin(angle) /10.;
anms->setRotation ( core::vector3df ( 0,angle,0 ) );
anms->setPosition ( core::vector3df ( myPos.x,myPos.y,myPos.z ) );
myPos is a struct with floats.