The code I am using from the tutorial for movement is this
Code: Select all
core::vector3df nodeRotation = node1->getRotation();
if(receiver.IsKeyDown(irr::KEY_KEY_A))
nodeRotation.Y += MOVEMENT_SPEED * frameDeltaTime;
else if(receiver.IsKeyDown(irr::KEY_KEY_D))
nodeRotation.Y -= MOVEMENT_SPEED * frameDeltaTime;
node1->setRotation( core::vector3df(nodeRotation) );
core::vector3df nodePosition = node1->getPosition();
if(receiver.IsKeyDown(irr::KEY_KEY_W))
nodePosition.Z -= MOVEMENT_SPEED * frameDeltaTime;
else if(receiver.IsKeyDown(irr::KEY_KEY_S))
nodePosition.Z += MOVEMENT_SPEED * frameDeltaTime;
node1->setPosition(nodePosition);Could anyone give me an idea as to how I would change the direction he is walking to be the direction he is facing when being rotated? I have done abit of searching on the forums and I gather I would possibly need to use a rotation matrix? But I am quite new to this and dont really understand.
Any help would be appreciated, thanks.