0 votes

hello, jou wanted to create 2 different types of controls to control "kinematic body 3d"
here is control 1 (up down left right):
https://drive.google.com/file/d/11-lGs32zYh4FkaEWs0giiTfBVSt52xSt/view?usp=sharing

I would like to insert a 2nd control for the touch screen with 4 buttons (up down left right) but I don't know how to do it, I don't know anything about buttons, their possibilities on the screen are like this:
https://drive.google.com/file/d/1iML--kcTa-7Sw9Rm8AV1Stfr1DHdQr91/view?usp=sharing

project link : https://drive.google.com/file/d/1wZiBxL07yib1M8XbHXDRCS4-2P-1PWQ_/view?usp=sharing
Additional project images :
https://drive.google.com/file/d/1aEms8vho89Yq3Jvzm1dVXFmZotl9YmJD/view?usp=sharing
https://drive.google.com/file/d/1MNVNcgyWI4M0bxC3hkXTEUmIRIgLnw72/view?usp=sharing
https://drive.google.com/file/d/1diXqkrEo2A1eZe_vxOU-U-FcEdKgvBX7/view?usp=sharing

asked Jun 8 in Projects by neutrino2020 (19 points)

1 Answer

+1 vote

Hi, so you'd need to add the buttons and lets say they are $Button_UP, $Button_DOWN, etc.

First of all, I recommend you move all that logic to a

func _input(event):

If not, you're checking for input in every iteration of that sprite when you shouldn't be.
So just copy and paste all the content of your _physics_process function but the move_and_slide(velocity) line and the rotate_z lines.

Then add to every condition needed, the $Button_(DIRECTION).pressed condition to check if the button is being pressed. So the first condition you have would look like this:

if (Input.is_action_pressed("ui_right") or $Button_RIGHT.pressed) and (Input.is_action_pressed("ui_left") or $Button_LEFT.pressed):
    velocity.x .....

Hope it helps. If you need further clarification, let me know.

answered Jun 8 by jtarallo (376 points)

thank you very much, you saved me a lot of time.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.