I'm using this little script to detect right clicks and I can't get them if I hover over hotspots and right click. Outside of the hotspots is fine though.
void OnMouseOver ()
{
if(Input.GetMouseButton(1))
{
Debug.Log ("Test"):
}
}
Basically I need this to dismount my sprite from mouse cursor.
Since there is no feature in AC to have an object follow mouse in a manner of as if you replaced mouse cursor image for another image. The other AC feature to follow mouse as a character or NPC won't do since it is kind of with a delay factor.
And I need an object/my sprite to move as if you replaced the cursor image.
So I make my sprite follow the mouse in my custom script but I need it to stop, thus I need to detect right click mouse, and It doesn't work if the mouse is hovering over hotspots.
Comments
It may be that your script is being executed after AC's PlayerInput script. Try altering it's order in Unity's Script Execution Order panel.
Also tried to include in the order other scripts AC.DetectHotspots, AC.PlayerCursor, AC.PlayerInteraction, AC.Hotspot, AC.Interaction beneath mine script.
You can retrieve the cursor's position with:
AC.KickStarter.playerInput.GetMousePosition ();
And then use it in your code.. In fact, the PlayerInteraction script's CheckForHotspots() function is how AC determines what Hotspots are under the cursor - you may find it useful to pick it apart.
Is there an option to limit only to left button and leave the right button for diselect, how?
if (_mouseState == MouseState.RightClick)
{
return;
}
public override void ProcessClick (AC.Menu _menu, int _slot, MouseState _mouseState)
{
if (KickStarter.stateHandler.gameState == GameState.Cutscene) {
return;
}
KickStarter.playerInteraction.ClickInteractionIcon (_menu, iconID);
}
}
Tried to insert it everywhere still can right click on hostpots.
I was referring to right-clicking on Interaction icons, however - right-clicking on Hotspots should only work for Context Senstive mode, not for Choose Hotspot Then Interaction. The only way I could see that happening is if you mapped the right-mouse button to the InteractionB input axis.
Insert the code below into line 292 of PlayerInteraction.cs. Let me know what the console says when you right-click on a Hotspot.
Debug.Log (KickStarter.playerInput.mouseState + " " + KickStarter.runtimeInventory.selectedItem + " " + KickStarter.runtimeInventory.hoverItem);
Now it is perfect I can't right click on the hotspots
Thanks Chris!