Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Diego Machado | |
Old Version | Published before Godot 3 was released. |
Hey guys, Godot noob here!
First of all, I know that the Input processing order is as follows:
I’m trying to make a Area2D
with a ColliderShape2D
(circle) clickable through CollisionObject._input_event()
.
It’s basically a target. If I hit any one of the targets it’s a score, else is a miss.
I started implementing the miss feature using input()
on the stage script, but then I discovered that it’s fired first and I can’t stop the input propagation in a CollisionObject._input_event()
, so, everytime I hit a target I also get a miss.
Then I decided to make Area2D
big as the stage to act as a miss collider. It works as expected, but it’s input_event()
is fired before the target’s input_event()
. So, again, first a miss then a hit.
-
How can I do this in a more elegant way?
-
I’ve thought about Raycasts. Is it simple to shoot a 2d raycast ‘through’ the screen and detect a hit? How could I do that?
-
Can I force the nodes
input_event
callback order? I’ve tried to use thePriority
property but it doesn’t seem to work. -
What it’s ‘Priority’ used for then?
-
What if I have overlapping
Area2D
’s?
Thanks! Hope you guys can help me!
as a temp solution for your problem only i believe you can remove the area2D and detect the hit using the geometry of a circle, calculate the distance of the mouse from the center of your circle and if it is less the 1 radius than it’s inside the circle, else wise it’s not…
rustyStriker | 2017-05-17 20:06
Actually that was kind of my first solution. I created a Rect2 based on the size of my Node’s sprite and used has_point()
to check if it was hit.
It worked, but it was painfull to tweak the size of it, because I wanted to make the hit area bigger than it’s sprite. I wanted some solution to make possible to see the hit area in the editor.
Diego Machado | 2017-05-17 20:24