Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rafallus
Copy link
Contributor

@rafallus rafallus commented Jan 27, 2022

Based on this proposal godotengine/godot-proposals#3818. input_event, mouse_entered and mouse_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:
GridMapsSignals
I include the project I used for testing.
GridMapTest.zip

Bugsquad edit: This closes godotengine/godot-proposals#3818.

@rafallus rafallus requested review from a team as code owners January 27, 2022 01:52
@rafallus rafallus force-pushed the gridmap_staticbody_signals branch 4 times, most recently from 30717d7 to 7c6c0af Compare January 27, 2022 03:00
@rafallus rafallus requested a review from a team as a code owner January 27, 2022 03:00
@rafallus rafallus force-pushed the gridmap_staticbody_signals branch 4 times, most recently from eb199e8 to 011cc76 Compare January 27, 2022 03:40
Comment on lines +61 to +63
#ifdef MODULE_GRIDMAP_ENABLED
#include "modules/gridmap/grid_map.h"
#endif
Copy link
Member

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.

Copy link
Contributor Author

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?

Copy link
Member

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).

CC @JFonS @RandomShaper

Copy link
Contributor Author

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.

Copy link
Contributor

@Zylann Zylann Jan 21, 2024

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replicate CollisionObject3D signals in GridMap
5 participants