Rotation Movement

Hi, there!!



As you guys can see, I'm really newbie in CG (I'm taking classes on that subject in college this semester). I would like to use the same system movement used in Neverwinter Nights in the game I'm working on (left and right arrows keys apply an rotation in the y axis of the character). Currentlly in my game, when the left arrow key is pressed, the character is rotated, and starts moving to the left! How can I use the left and right arrow keys to apply rotation only, not translating the character in the process???



Thx, guys!



public void update(float tpf) {
        float speed = tpf*100;
        movimentoAndando();
     }
        
    public void initInput(){
       
       keyboard.set("forward", KeyInput.KEY_UP);
       keyboard.set("backward", KeyInput.KEY_DOWN);
       keyboard.set("right", KeyInput.KEY_RIGHT);
       keyboard.set("left", KeyInput.KEY_LEFT);
      
    }
       
    public void movimentoAndando(){
       Principal.players.getLocalRotation().normalize();
        Principal.players.getLocalTranslation().normalize();
       
       if(keyboard.isValidCommand("forward")) {
          System.out.println(Principal.players.getLocalRotation());
          Principal.z = Principal.players.getLocalTranslation().z;
         Principal.players.getLocalRotation().y = 0f;
          Principal.players.getLocalTranslation().z -= .5f;
          
          if(andando == false){
             Principal.setKeyFramesPlayer(0.9f, 1.5f, 1, Controller.RT_CYCLE);
             andando = true;
             
          }
      }
       else if(keyboard.isValidCommand("backward")) {
          System.out.println(Principal.players.getLocalRotation());
          Principal.z = Principal.players.getLocalTranslation().z;
          Principal.players.getLocalRotation().y = -1.0f;
          Principal.players.getLocalTranslation().z += .5f;
          if(andando == false){
             Principal.setKeyFramesPlayer(0.9f, 1.5f, 1, Controller.RT_CYCLE);
             andando = true;
          }
       }
          
       else if(keyboard.isValidCommand("right")) {
          System.out.println(Principal.players.getLocalRotation());
          Principal.x = Principal.players.getLocalTranslation().x;
          Principal.players.getLocalRotation().y = -.7f;
          Principal.players.getLocalTranslation().x += .5f;
          if(andando == false){
             Principal.setKeyFramesPlayer(0.9f, 1.5f, 1, Controller.RT_CYCLE);
             andando = true;
          }

       }

       else if(keyboard.isValidCommand("left")) {
          System.out.println(Principal.players.getLocalRotation());
          Principal.x = Principal.players.getLocalTranslation().x;
          Principal.players.getLocalRotation().y = .7f;
          Principal.players.getLocalTranslation().x -= .5f;
          if(andando == false){
             Principal.setKeyFramesPlayer(0.9f, 1.5f, 1, Controller.RT_CYCLE);
             andando = true;
          }
       }
       else if (andando == true){
          Principal.setKeyFramesPlayer(0f, 0.6f, 1, Controller.RT_CYCLE);
          andando = false;
                    
       }
       
    }

…or some example that I can see…

Rotation only:



        Matrix3f incr = new Matrix3f();
        Matrix3f tempMa = new Matrix3f();
        Matrix3f tempMb = new Matrix3f();
        float speed = node.turnSpeed(); //made up for example
        incr.loadIdentity();
        if(turnRight) {
               speed *= -1; //go negative for right,  positive for left
        }
        incr.fromAxisAngle(new Vector3f(0,1,0), speed * evt.getTime());
        node.getLocalRotation().fromRotationMatrix(
                incr.mult(node.getLocalRotation().toRotationMatrix(tempMa),
                        tempMb));
        node.getLocalRotation().normalize();



Pretty much from KeyNodeRotateAction.

Does that do what you need?

Hi mojo!



I think I made something newbiesh…but it worket…Just tell me if its really, really wrong…?! :lol:



public void simplesMovimento(){