Hello again!
So I'm using Direct movement method, and I want to interact with object only when I'm close to it and press 'E', but the problem is that the interaction also triggers if I click left mouse button. I hope in this case, my mouse will not work as 'InteractionA', but will also work for inventory items and menus. (This is the reason why I don't check Mouse clicks have default functionally?)
How can I achieve this?
Unity version: 2022.3.41f1c1
AC version:1.81.6
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
Are you relying on Unity's new Input System, or the legacy Input Manager, for input?
If you have Mouse clicks have default functionally? unchecked, then mouse clicks should only run Hotspot interactions if you have "mouse 0" mapped to your InteractionA input. Unity UI-based Menus may also respond to the mouse via the Submit input, however.
If you want to allow for the mouse to be used in Menus, you can override the input logic code through script. See the Manual's "Remapping inputs" chapter for details, but if you can share more information about your exact needs with this I can give more specific advice.
I'm using the Input Manager (old), I didn't assign mouse0 to InteractionA, I just assume that the left mouse click works just like InteractionA by default.
I mean, if I unchecked Mouse clicks have default functionally?, I can't click the AC menu. (It works for unity UI, but I use AC menu mostly.)
I hope my mouse click works as fine as usual and doesn't trigger the action like 'InteractA', because 'E' is already handling that job in my project.
Can this be easily done? Cause I have no idea about the coding.
A custom script can override AC's "InputGetButtonDown" function such that - when the mouse is over a Menu - it reads the mouse button, rather than "InteractionA".
This should do it:
Thank you but sadly, it caused an initialization error, everything got stuck at the beginning of the game.
I hooked it to an empty object, then I received this report:
ArgumentException: Input Button ToggleCursor is not setup.
To change the input settings use: Edit -> Settings -> Input
UnityEngine.Input.GetButtonDown (System.String buttonName) (at :0)
InputOverride.My_GetButtonDown (System.String axis) (at Assets/New code/disable mouse/InputOverride.cs:18)
AC.PlayerInput.InputGetButtonDown (System.String axis, System.Boolean showError) (at Assets/AdventureCreator/Scripts/Controls/PlayerInput.cs:1898)
AC.PlayerInput.UpdateInput () (at Assets/AdventureCreator/Scripts/Controls/PlayerInput.cs:242)
AC.StateHandler.Update () (at Assets/AdventureCreator/Scripts/Game engine/StateHandler.cs:159)
It requires me to setup all the AC inputs. And checking Assume inputs are defined? will still cause the same problem.
I made it! I added all the AC inputs, including CycleHotspotsLeft and CycleHotspotsRight, which were not listed in Setting - Input, problem solved.
Thank you so much!
Sorry - I left out the try/catch statement. If you use this, then you can have Unity ignore missing inputs:
Thank you so much!