I need help with some movement coding

This is my first time coding using java, and I needed a lot of help. I used a tutorial video from 2016 and so far I haven’t had many problems. However, Java has definitely changed since 2016. So I just need some solid movement codes that will work with modern Java pls help.

Hi @Rusty_Shackleford and welcome,

You can start with this tutorial:


1 Like

I think the tutorial is blocked or something. And the script on there gives me an error when I run it. I would honestly love if something in this project went my way. Can I just get a movement script and then get the camera to move later?

What do you mean blocked? Works for me.

Here is the simplest moving script I could think: Basic Keyboard Input | Learn PlayCanvas

Okay, I got the code to work slightly. however, I did use a bit of code I found from another movement script just using instead of angles changing, a: this.entity.translatelocal(X,Y,Z) It worked well except when I tried to go backwards, in my case, S, it gave me an error saying: this.entity.translatelocal isn’t a function. It didn’t say it on the other lines for W,A,and D. Just the line with the translatelocal values: 0,0,0.1 Why is that?

Hi @Rusty_Shackleford!

Be sure you use it inside the update function with a capital letter L.

this.entity.translateLocal(0, 0, 0.1);

Okay I’ll try that. I kind of gave up on that script, so I copied the advanced movement script and it basically worked. However, the controls have this weird quirk to them where they only let you move diagonally. So I can’t just press W, I have to also press A or D. I need some help with that. I also need help adjusting player move speed and fall speed. You just change the default Power variable right? I also noticed my walls’ collision boxes don’t work if you hit them backwards.

I realized you need them to have rigid bodies. The controls are still really weird and only work sometimes.

or not, still no box collision. darn

Can you share a link of your project, so I can take a look?