KinematicBody2D direction/rotation towards finger touch in Godot 3

42 Views Asked by At

I've tried a lot to rotate/Direct a kinematicBody2D(Player) in the direction of finger touch. But I wasn't able to do so. Actually, the problem is that in order to move the player there is a need to tap the virtual joystick. So, the player continuosly looks only at the touch on joystick. I'm unable to rotate/Direct it towards the other finger touch.

I tried to use and Area2D on virtual joystick, and then emitting a signal when mouse entered(finger touch) which results in assigning a variable false, which should have resulted in Player not looking towards joystick. But joystick stopped working due to this. Then I tried to use range function to compare the mouse(finger touch) coordinates with a range of coordinates ,i.e., range for x = 400px and so is true for y. But it also didn't worked. I thought I could have used range function incorrectly. But still I doubt this logic to be working. And lastly I tried to move/Direct by using custom actions. Those actions will be produced when joystick will be moved in a specific direction. But it still didn't worked. I was able to use this to rotate Spriteimage but it kept continuosly rotating. And also used a second joystick which also didn't worked as i wasn't able to create ideal logic reauired for it.

0

There are 0 best solutions below