Virtual WASD help

Hi. Just wanna ask for some help on how to activate the virtual buttons for first-person movement on desktop and mobile, thank you in advance

https://playcanvas.com/editor/scene/1298032

Hey @Genesis_Miranda,

Check out this guide on how to implement buttons in PlayCanvas, and this tutorial on how to detect input, including touch input. Hope this helps!

Hi, thanks for the response, sorry I’m just starting with playcanvas programing. I tried to follow the tutorial you sent and works great, just wanna ask how can I make the button to act as a keyboard input? i.e button W = KEY_W ? thanks again

Just to understand the purpose a bit better, why would you need it to detect a keypress on button click? Is it to use the same script for your desktop controls on mobile?

Yes sir. I just need the buttons to work the same way as the firstperson controller, is that possible sir? thanks

Hey,

Yes, this should definitely be possible, but you don’t need to detect the keypress itself. Rather, perform whatever action the keypress was performing when you detect a button click. And if you need mobile controls for a first person controller, you can also check out the seemore project for a more advanced mobile control mechanic.

got it sir, thanks

I can then add the script to any button right? I’m still having issues for the proper script. sorry for bothering again, but can I ask what’s the right script should I use to make the Button W move forward? thanks again

Hi @Genesis_Miranda! The script you need to detect a button click is on the page @DevilZ shared in his first post. You can adapt the script to your needs. Can you share a link of your project please, so we can see your progress? If your project is private, maybe you can share the script or some screenshots.

1 Like