Topic was automatically imported from the old Question2Answer platform.
Asked By
CesarAugusto
Old Version
Published before Godot 3 was released.
Hello!
Supose I have a gesture detector node which returns the position when someone tap the screen (in case of mobile game), how can I check if this position is inside an Area2D? The signals body_enter and input_event won’t work for me in this case, I guess.
There is probably a better way to do this, but the first thing that popped into my mind was to create a collision body or area2d node without sprite, and move it to the vector position in order to trigger the Area2d event.
I was thinking the same thing right after I posted this. Do you know a better way to check without a Area2D?
CesarAugusto | 2017-08-30 01:11
Researching the Area2D found that you could get the collision shape by calling get_shape. This returns a Shape object that has the method collide. This method gets the local transform, another shape to test against and this shapes transform. You can check it on the docs. Its probably no the best solution, but it’s a step forward and a more elegant solution than the previous one.