touch position way off

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Tentamens

Hi there!

so I want to spawn something where I press on the screen (touch screen game) but when I’m pressing in the position area of around 1500 - 1000 but it spawns in around 350 - 557 give or take a few

code -

func _unhandled_input(event):
if event is InputEventScreenTouch and event.is_pressed():
	print(event.position)
	var new_instance = PopUp.instance()
	self.add_child(new_instance)
	new_instance.position = event.position
	print(new_instance.position)

when I print the event.position it does say around that 355 to 500 with some offset of where my press was

I’ve had some problems like this before and I set the scale of the nodes to 1-1 but they all already were so I’m at a loss any ideas?

Big thanks ahead of time!

What happens if instead of this:

new_instance.position = event.position

You do this:

new_instance.global_position = event.position

jgodfrey | 2022-08-25 22:23

Hi, thanks for the response!

that doesn’t fix the issue (from what I can see) because event.position is still off by some 1000+ position . actually, I think I found the issue but I don’t know how to fix it, the position is going on the screen, not the world, and If I try to use event.global_position
it throws me an error Invalid get index 'global_position' (on base: 'InputEventScreenTouch').

big thanks again!

Tentamens | 2022-08-26 00:51

Maybe something in this thread is helpful?

https://forum.godotengine.org/28543/godot-3-0-2-get-global-position-from-touchscreen

jgodfrey | 2022-08-26 03:27