0 votes

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!

Godot version Godot v3.4.4
in Engine by (99 points)

What happens if instead of this:

new_instance.position = event.position

You do this:

new_instance.global_position = event.position

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!

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.