I need help with moving

I used keys for moving but I get a error and don’t know why it is not working I tried to find the error but I can’t find it.

Hi @Rohitgicool_Cool! Can you show your code and the error that you get?

Hi @Rohitgicool_Cool,

Try changing line 10 of your code from:

if (this.app.keyboard.isPressed(pc.input.KEY_UP)) {

to:

if (this.app.keyboard.isPressed(pc.KEY_UP)) {

Does that help at all? Check out this page of the user manual for more information on Keyboard Input:

https://developer.playcanvas.com/en/tutorials/keyboard-input/

1 Like


I did the adjustment and it still does not work.

Hi @Rohitgicool_Cool! Please try to use isPressed instead of wasPressed.

To help you understand what @Albertos suggested a little better, perhaps it is best if you read the documentation on this topic - Basic Keyboard Input | Learn PlayCanvas. You can also study the tutorial further to learn different ways of detecting keyboard input in your PlayCanvas game or app.

Hope this helps!

2 Likes

It still does not work.

Can you share a link of your project please?

1 Like

I think my device does not work because I am using Bluetooth keys on a iPad. https://playcanvas.com/editor/scene/1314558
This is the link

Two problems in your project. The script need to be attached to your Box entity and your Box entity need a kinematic rigidbody with your current code.

1 Like

But when I try to do kinematic rigidbody it doesn’t have any gravity like the box doesn’t move down it doesn’t fall

Hi @Rohitgicool_Cool and welcome back!

That’s correct. If that’s not an option for you, you have to change the way of movement. If you want to use a dynamic rigidbody you need to apply a force on the rigidbody of the entity.

https://developer.playcanvas.com/en/tutorials/Using-forces-on-rigid-bodies/