So in my game you can punch by left clicking.
However you also have to click doors to open them and click items to pick them up.
This means everytime u open a door or pick up an item you punch which is very annoying.
Is there anyway to check if a player is hovering over a click detector? Maybe detect the cursor icon itself changing? since it changes when your hovering over something you can click.
You can use the MouseHoverEnter and MouseHoverLeave events of the click detector to do this. An example would be to set a boolean value to
MouseHoverLeave. Then, simply check for this boolean when attempting to punch.
If there are certain areas where punching isn’t needed you could use a region or zone part and have your punching function detect that and not punch.
I guess this wouldn’t work for mobile since they just tap the screen once. But maybe he doesn’t have mobile users.
Good point. I searched up a couple posts about this, and it seems that (from what I’ve read) on mobile you will need to tap a ClickDetector twice in order for it to trigger. After doing some tests, I’ve discovered that on the first tap, MouseHoverEnter fires. If you tap somewhere else other than the click detector, it will fire MouseHoverLeave.
I do not have any mobile users. strictly a PC game lol.
@Sir_Highness that isn’t a viable option for me sadly with the way my game works.
Emeralds solution should work if I just get every click detector on the client and set up an event on them. Thanks!
How about this… the click dectector hover creates or updates a value in the character, maybe a bool, call it mousehover. Have the click detectors set mousehover value to true/false when it detects. Then, have your punch script check the value and only punch if mousehover.Value == false.
This is exactly what the first reply suggested.