VR Character Script

Hey, I’m having some issues with the code that is attached to my character. It’s not functioning properly and causing the character to move in a jerky and unsmooth way. Do you know what might be causing this problem?

Here’s the link to my game & the scripts:
https://playcanvas.com/editor/scene/1711745

https://playcanvas.com/editor/code/1058899?tabs=129434017&line=22&col=47&error=true
https://playcanvas.com/editor/code/1058899?tabs=129434017,129432188

@Pixels First I am not really sure that this is VR. It looks like third person to me. Also, I am not seeing in your code where you change the animation back to idleanimation. I think what is happening is that when this starts up it is already in the walkanimation state. Similarly when you do use the WASD movement it sets it to walk. Once the user releases the WASD then you should change the state back to idle. If you got the animations from Mixamo be mindful that you should select walk in place option. This way the character will not move forward of it’s actual position. One last thing. I see that there are two scripts that create actions based on the WASD keys. They could fight against each other once you get the above fixed.

In the script with the error please look below

ty// update code called every frame
GirlMovement.prototype.update = function(dt) {
    if (this.app.keyboard.isPressed(pc.KEY_W)) {
        this.entity.rigidbody.applyForce(0,0,5);
    }

    if (this.app.keyboard.isPressed(pc.KEY_A)) {
        this.entity.rigidbody.applyForce(5,0,0);
    }

    if (this.app.keyboard.isPressed(pc.KEY_S)) { // <<<<<<<<<<<<<< this has two ending
        this.entity.rigidbody.applyForce(0,0,-5);
    }

    if (this.app.keyboard.isPressed(pc.KEY_D)) {  //<<<<<<<<<<<< Missing )
        this.entity.rigidbody.applyForce(-5,0,0);

        
    }
};
1 Like