What I wanted to know is how do I get a scene node to move forward(local translations) or strafe?.
Thanks
![Very Happy :D](./images/smilies/icon_biggrin.gif)
Have you tried searching the forums a bit? I know I've seen quite a few threads on this in the past. More specifically the "Code Snippets" section.3DModelerMan wrote:Hi I am trying to create a game with a 3RD person perspective. I have the camera system worked out now I'm fine tuning it.
What I wanted to know is how do I get a scene node to move forward(local translations) or strafe?.
Thanks.
Code: Select all
// whatever condition u use for moving u're node
if(((input->x_axis>300) ||
(input->x_axis<-300)||
(input->y_axis>300) ||
(input->y_axis<-300))&&
(input->action==TPS_IDLE)){
// direction you dizire from input
f32 floatDeg = atan((f32)input->y_axis/(f32)input->x_axis)*RADTODEG;
vector3df rotation = vector3df(-90,floatDeg,0);
//set up rotation vector from camera position and the node position
f32 camRot = (camRefPosition-node->getPosition()).getHorizontalAngle().Y+90;
rotation.Y+= camRot;
rotation.Y-= node->getRotation().Y;
rotation.X = 0;
rotation.Z = 0;
//rotate your node, if strave dont rotate it
node->setRotation(node->getRotation()+rotation);
//move your node---->
if(input->useRunSpeed){
input->accelerate = 2;
}else{
input->accelerate = 1;
}
}else{
input->accelerate = 0;
}
if(input->accelerate>0){
switch(input->accelerate){
case 1:
walk();
break;
case 2:
run();
break;
case 3:
stepBack();
break;
}
}else{
idle();
}