Hello,
I messed some of my code up and I don’t know how to fix it, could you by any chance send me the script for First Person Movement?
Thank you in advance
Hello,
I messed some of my code up and I don’t know how to fix it, could you by any chance send me the script for First Person Movement?
Thank you in advance
Hi @Drew_Berner,
You can find it here:
https://developer.playcanvas.com/en/tutorials/first-person-movement/
At the same time take a look at this page, it contains a big list of tutorials and example projects to help you out:
yeah but could you just copy paste it for me.
Hi @Drew_Berner!
Is there a reason why you can’t copy and paste it from the project yourself?
Because I can’t find it.
You can find the script in the script folder of the asset panel. You can also find the script on the script component of the player entity.
Nevermind that now, I figured it out! But I have a different problem, I need to know how to make my player run with the SHIFT_KEY. Could you help me with that?
The speed is controlled by the value of this.power
. It’s applied after all key press checks, that you can find in the update function of the script.
if (x !== 0 && z !== 0) {
force.set(x, 0, z).normalize().scale(this.power);
this.entity.rigidbody.applyForce(force);
}
You could probably replace that part of the code with something that adds some extra power when the player presses the Shift key.
if (x !== 0 && z !== 0) {
if (app.keyboard.isPressed(pc.KEY_SHIFT)) {
force.set(x, 0, z).normalize().scale(this.power * 2);
}
else {
force.set(x, 0, z).normalize().scale(this.power);
}
this.entity.rigidbody.applyForce(force);
}
Thank You
If I could choose anyone to help me with something, I would choose you, you are helpful.