Hey guys,
I need a button on screen to simulate pressing the 0 button when clicked while activating an action list at the same time.
Do you have any idea how to do this?
I know you can simulate input by using the "simulate input" menu click type but I can't think of a way to make it run an actionlist after.
Thank you
Comments
This is done using "Active Inputs" - see Section 2.6 of the Manual. Be aware that the "Input name" you set must be the name of the input as listed in your Unity Input Manager, not the name of the key that must be pressed.
Ignoring the custom code / simulation for the moment, focus on just getting the Active Input to work. You can quickly determine if the ActionList is run by adding an ActionList: Comment Action to it so that a log can be printed to the Console when run.
Once the Active Input runs when pressing the "0" key on your keyboard ("[0]" is required for the keypad, see this page), then we can focus on having it simulated.
For example, if the Menu pauses the game, the Active Input will have to be set up to respond when the game is paused.
You can test this out quickly by creating a new Active Input that works when the game is "Normal", and changing the default InGame Menu's MenuButton to have a Click type of Simulate Input, and entering in the name of the Unity input axis into the field that then appears.
Again you should be using C# if you want to use scripts in conjunction with AC. You say the AC side of things is working in that the Active Input and the simulated button both work, so it sounds like the issue lies instead with your own scripts. How are you calling those scripts in the pianorecord ActionList? With an Object: Send message Action?
I'll jump in to help a bit and transfer your JS script to C#. Make a new C# script called TestScript and paste this in it:
Here
Perhaps something needs to be put in the script to work with AC?
You don't need a script to read Unity.GetKeyDown - that's what Active Inputs do for you! At the moment, you're doing both - so there's no way to know if the code is running because it's from your own script, or due to the input.
You need to include a public function in your script that the Active Input's ActionList invokes. It will then be available to select when using the Object: Call event Action.
Remove the Input.GetKeyDown code in a new test script, and again go back to just having the Active Input invoke it - you can place a Debug.Log statement in the public function to confirm that AC is running it. Only once that is working, you should go about having it work with a simulated button.