Here’s my code:
func _input(event):
if event is InputEventScreenDrag:
rotate_y(event.relative.x * -look_sensitivity)
camera.rotate_x(event.relative.y * -look_sensitivity)
camera.rotation.x = clamp(camera.rotation.x, -PI/2, PI/2)
Here’s my code:
func _input(event):
if event is InputEventScreenDrag:
rotate_y(event.relative.x * -look_sensitivity)
camera.rotate_x(event.relative.y * -look_sensitivity)
camera.rotation.x = clamp(camera.rotation.x, -PI/2, PI/2)
I’m not entirely sure what you want to achieve, but if I understood correctly you want to capture only event that is dragging from right to left side?
Then, you can check if event.relative.x < 0
. This should catch only right-to-left drags.
func _input(event):
if event is InputEventScreenDrag and event.relative.x < 0:
rotate_y(event.relative.x * -look_sensitivity)
camera.rotate_x(event.relative.y * -look_sensitivity)
camera.rotation.x = clamp(camera.rotation.x, -PI/2, PI/2)
Yes, i want for the event to capture from the right side of the screen. But, your code is not working very well, it’s glitching when i try to move the camera on my android phone.
What do you mean it’s glitching? Can you show a recording?
It is doing exactly what you asked for - it filters out left-to-right drags and allows only right-to-left drags.
But I think what you meant is that it should allow the drags only on the right half of the screen and not the left side of the screen? Then you need to check the position of the event in relation to the viewport size.
func _input(event):
if event is InputEventScreenDrag and event.position.x > (get_viewport().size.x / 2):
rotate_y(event.relative.x * -look_sensitivity)
camera.rotate_x(event.relative.y * -look_sensitivity)
camera.rotation.x = clamp(camera.rotation.x, -PI/2, PI/2)
Yeah, it worked but it’s a little delayed but that’s no problem.