-
-
Notifications
You must be signed in to change notification settings - Fork 21.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add mouse input interaction to GridMap
#57289
base: master
Are you sure you want to change the base?
Conversation
30717d7
to
7c6c0af
Compare
eb199e8
to
011cc76
Compare
011cc76
to
337a29b
Compare
#ifdef MODULE_GRIDMAP_ENABLED | ||
#include "modules/gridmap/grid_map.h" | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think having GridMap creep its way into something as core as Viewport will be acceptable.
I'm not sure how this should be done but this is probably not the way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could a unhandled_input_picking
signal from the viewport work? That way GridMap can connect to it and receive the information needed. If yes, should the signal be exposed to GDScript?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That might work, though I'm surprised that there wouldn't be an existing system that can be suitable for GridMap. It's not the only node / editor that handles picking and if other gizmos can do it, then GridMap should be able to do it too (just talking in principle - I'm not actually familiar with that code and might be wrong).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, that can certainly be done with the normal unhandled_input
. But since the viewport is already checking for collisions I think that can be used and avoid repeating code. Also, the process_picking
method (the one that takes care of collisions) is called inside physics_process
of the SceneTree. If we want the input to also be processed in GridMap's physics_process
, the inputs should be collected first and then processed. To me, that's a bit too much for something that is already implemented and can be reused.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would be interested in having a generic way to connect to this too in my plugins, because this issue is not specific to GridMap: godotengine/godot-proposals#3818 (comment)
Based on this proposal godotengine/godot-proposals#3818.
input_event
,mouse_entered
andmouse_exited
signals are implemented.This can avoid the trouble found when raycasting on GridMap's shapes (see #46561).
With this implementation it becomes much easier to do things like this:
I include the project I used for testing.
GridMapTest.zip
Bugsquad edit: This closes godotengine/godot-proposals#3818.