Syntax for accessing a certain Input Actions' properties via script...
Hello,
So, I'm working on an options menu which enables the player to rebind controls. I've been looking at a lot of tutorials out there that use "point & click" with a button, but the mouse is disabled in my game, so that isn't an option. I already have it set up so the player can select the button they want to change by controlling a cursor over the five inputs I want them to have the option to rebind: "Jump", "Shoot", "Melee", "Special" and "Ultimate".
The thing is, my game was originally made using the old input system, but I've since converted to the new one. The problem is, I'm a bit lost when it comes to the syntax of accessing these actions and inputs. Even with the various tutorials on rebinding I've watched, I couldn't find the lines of code I need.
So, my main questions are:
1) How do I declare a specific input action within a script? The input action I want to access is called "PlayerInput" (and is in a folder called "InputActions", in case that matters). If I've understood the tutorials I've seen correctly, you declare an input action in a script like this: [SerializeField] private InputActionReference jumpAction; However, I haven't seen how to specify it to a specific input action (I have 4 different input actions in my project).
2) Related to the first question, but does "PlayerInput" need to be on an object in the scene for me to be able to access it via script (and perform rebinds on it)? The menu being used to select the rebind options are using a different input action file.
3) For displaying the currently set inputs, how do I access the individual inputs within "PlayerInput"? Watching various tutorials, I got as far as this: jump1Txt.text = InputControlPath.ToHumanReadableString(jumpAction.action.bindings[0].effectivePath); Right now though, it returns as undefined, as I'm unsure how to access a specific input action, nor specify the certain actions within it.
Thanks in advance to anyone who can help with this. I know where I need to put these lines of code, I just don't know what the correct syntax is.
Your answer
Follow this Question
Related Questions
SteamVR Beta Input Action Issue 1 Answer
problem when using 2 actions map in new Input system. 0 Answers
I there a way to record player input and play it back once the game has stopped? 2 Answers
New Input System only sometimes registering release of key 0 Answers
Problems with touch input. 0 Answers