This code appears to have worked for my project. Note: You must enable emulate touch from mouse in the project settings in order to test on the computer.
extends TextureButton
signal CameraPivot
@export var sensitivity = 0.5
var lastPosition = null
func _input(event):
#print(event.as_text())
if event is InputEventScreenTouch:
#print(event.position.x)
if event.canceled:
lastPosition = null
elif event.pressed && lastPosition == null:
lastPosition = event.position.x
else:
lastPosition = null
elif event is InputEventScreenDrag && lastPosition != null:
#print("Drag")
var displacement:float = event.position.x - lastPosition
var angle:float = displacement * sensitivity
#print(displacement)
lastPosition = event.position.x
CameraPivot.emit(angle)
else:
pass
#lastPosition = null
This code appears to have worked for my project. Note: You must enable emulate touch from mouse in the project settings in order to test on the computer.