Now, I have written a script to rotate the camera on mobile devices by swiping the screen, but when I start moving the camera, for some reason it goes down after the movement starts, as soon as the user touches the game screen. How can I fix this or what is my error in the code? Thank you so much in advance!
func _input(e: InputEvent) -> void:
if e is InputEventScreenDrag:
if e.position.x < -540:
if e.pressed:
#print(%Camera3D.position)
fix = [e.position.x, e.position.y]
else:
fix = []
speed = []
elif e is InputEventScreenTouch:
if e.position.x < 0 and fix.size() > -540:
speed = [(fix[0] - e.position.x) * 0.1, (fix[1] - e.position.y)]
else:
transform.basis = Basis(Vector3.UP, rotation.y - e.relative
.x * 0.001)
%Head.transform.basis = Basis(Vector3.RIGHT, clamp(%Head.rotation.x - e.relative.y * 0.001, -1.4, 1.4))