Topic was automatically imported from the old Question2Answer platform.
Asked By
grafyan
I want to know at which position the player touches on phone so i can send the bullet right there. But im confused how to use InputEventScreenTouch. I tried InputEventScreenTouch.get_position() but that doesn’t work.
func _unhandled_input(event):
if event is InputEventScreenTouch and event.pressed == true:
(event.position) # the position of the touch
InputEventScreenTouch and things like InputEventKey and so on just describe the input event, so you use if event is Input... to first check if the event is the right one, before running any code on it (or else you’ll get errors).
In this case it’s also necessary to check if event.pressed == true or else the code will run also run when the player un-touches (twice in one tap).