Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | WannabeDev |
Hello I’m creating a farming system for my game. I have a StaticBody2D with a CollisionShape2D acting as the crop, it detects if the mouse is hovering it . When I hover my mouse over the node it fires the mouse entered/exited signal without issue, but lets say I keep my mouse still and move my player, the camera will shift with the player but if the mouse happens to hover over any another crop node after the camera shift it doesn’t fire the mouse enter/exited signal unless I move the mouse. Is there a simple way to fix this behavior or should I try to intersect the position of the mouse whenever the player gets close to the crop to verify it is hovering it?
Just for clarification: the mouse enter/exit signals work as intended. But when the player node is in that position, the signals don’t function as intended? So you’re trying to find a way to have the spot consume the mouse input without the player node consuming it?
Ertain | 2022-07-15 23:32
Yes the signals work as intended
Forgive me for the crude edits, the red dot would be the mouse
if I move the mouse on top a the potato object the enter/exit signal works as intended
if I leave the mouse on the same position and only move the player to the right side even though the mouse is on top of another potato that potato object doesn’t fire its enter/exit signal, if I stayed on the same position while only moving the mouse between both nodes, both would fire their signals.
WannabeDev | 2022-07-16 00:25
I still don’t quite understand your problem. Do you want to move the player character over some object and have the mouse detect the object? The thing is, the StaticBody2D
will detect the mouse cursor entering and exiting the collision. If the mouse cursor isn’t moved (i.e. no motion), no mouse-related signals are emitted. When the player character moves, any body collisions that are set up by the StaticBody2D
can detect the character.
Ertain | 2022-07-16 05:04
What I want is to detect when a motionless mouse happens to hover a object as a result of a player movement.
I have a area2D to check if the player is within the interaction range I might just use that with the physics process to intersect the mouse position while the player is within that range.
WannabeDev | 2022-07-16 11:58