Character movement.

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
3DModelerMan
Posts: 1691
Joined: Sun May 18, 2008 9:42 pm

Character movement.

Post by 3DModelerMan »

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 :D .
That would be illogical captain...

My first full game:
http://www.kongregate.com/games/3DModel ... tor#tipjar
Rytz
Posts: 249
Joined: Wed Oct 25, 2006 6:05 am
Location: IL, USA
Contact:

Re: Character movement.

Post by Rytz »

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 :D .
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.
Image
B@z
Posts: 876
Joined: Thu Jan 31, 2008 5:05 pm
Location: Hungary

Post by B@z »

there are a LOT of TPS cameras xD
did you searched just a little ? :D
3DModelerMan
Posts: 1691
Joined: Sun May 18, 2008 9:42 pm

HMMMMM

Post by 3DModelerMan »

Yeah I searched... maybe if someone could just point me to one of the threads?.
Thanks. :D
That would be illogical captain...

My first full game:
http://www.kongregate.com/games/3DModel ... tor#tipjar
B@z
Posts: 876
Joined: Thu Jan 31, 2008 5:05 pm
Location: Hungary

Post by B@z »

kornwaretm
Competition winner
Posts: 189
Joined: Tue Oct 16, 2007 3:53 am
Location: Indonesia
Contact:

Post by kornwaretm »

this is a movement code that relative to camera position, but it's need alot of modification to use on your case. i use gamepad to move my character, that is why i can get the x_axis ( signed integer ) and y_axis ( signed integer ).

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();
}
3DModelerMan
Posts: 1691
Joined: Sun May 18, 2008 9:42 pm

thanks

Post by 3DModelerMan »

Thanks that's probably going to work. :D
That would be illogical captain...

My first full game:
http://www.kongregate.com/games/3DModel ... tor#tipjar
TimVasko
Posts: 9
Joined: Thu Jun 26, 2008 7:25 pm
Location: Maryland, US

Post by TimVasko »

use camera parameters. Apply transformations to the player's position based on where the camera is facing (the direction vector. You can ignore the 3rd dimension if you don't want the player to move up and down). Strafing is done in a 90 degree angle so do a dot product or something (forgot math you can look it up) and then apply that transformation vector to node's position.

Thats how I used to do it.
---------
I'm on your side.
---------
Post Reply