Issue with movement script

MovementScript.prototype.update = function(dt) {
if(app.keyboard.ispressed(pc.KEY_W)){
this.entity.translateLocal(1,0,0);
}
};
i took a realitively old tutorial, so i need some help. it says APP is not defined, plz help.

app is not defined indeed.
You can either use pc.app or this.app for it to work.

    pc.app.keyboard.isPressed
1 Like

Hi @vilothaine_2,

Try formatting your code when posting on the forums, it makes it much easier for people to read:

MovementScript.prototype.update = function(dt) {
   if(this.app.keyboard.isPressed(pc.KEY_W)){
      this.entity.translateLocal(1,0,0);
   }
};

1 Like

@vilothaine_2, also make sure to use the correct capitalization for each method, all JS methods are case sensitive:

ispressed() should be isPressed()

I would also suggest you use rigidbody movement rather than translate it directly.

oh…

how do i do that?

Hi @vilothaine_2,

Check the following tutorial on how to move an entity using physics:

https://developer.playcanvas.com/en/tutorials/first-person-movement/

ok