I have tried to code, but have failed, I can’t figure out how to make my own movement system, if I could get help it would be awesome.
Hi @Gavin_Durbin! It would be nice if you let us know what code you are using and what problems you have with it.
trying to get a controller for movement, I can’t figure out how to use a command to check for key presses
// check for key press inside update function
if (this.app.keyboard.isPressed(pc.KEY_W)) {
// move forward
}
when I do that it says keyboard is undefined tho…
Where are you using that code?
hold on a min…
nvm, it works now.
in the game when i try to parse it it says “keyboard is undefined”
Yeah, because your code runs outside of your script context. Try putting it inside the script update method. Check this:
https://developer.playcanvas.com/en/user-manual/scripting/anatomy/
And the first person movement tutorial, you can see that code lives inside the script update method:
https://developer.playcanvas.com/en/tutorials/first-person-movement/
FirstPersonMovement.prototype.update = function(dt) {
}
I dont understand either, just tryin to make a game
Just setting it up, I’m new to coding, also want to understand how to code it in, the movement system, just getting to it, and using it