- Home /
How to convert new unity input system input actions to booleans
So I've looked around quite a bit for this and haven't had much luck. I'm pretty new and guess that this is a pretty simple problem but I can't seem to find the answer anywhere. I'm trying to transfer a game's input system from the old one to the new system so I can add gamepad support. I'm trying to use a Brackey's tutorial.
Before I was using a simple Boolean method for input
jumping = Input.GetKeyDown(KeyCode.Space);
But when I try replacing that with
jumping = controls.Player.Jump
(I've checked and all of those words are correct)
I get this error:
error CS0029: Cannot implicitly convert type 'UnityEngine.InputSystem.InputAction' to 'bool'
So is there a way to get a boolean from new input, or should I go about this another way entirely? Thank you for any answers.
Answer by sacredgeometry · Apr 05, 2020 at 02:54 PM
InputAction is an action. You dont need to convert it to a bool you just set the callback to a method with the correct signature and when the event happens it will call that method. If you want to set a bool as a result of it just add the bool setting code to the body of that method/ function.
Thank you! Yeah, it seems I didn't understand how the new system worked in the slightest lol, but with your help (and a little more Brackeys) I figured out how to use the new system
Your answer
Follow this Question
Related Questions
Simple GUI Problem... 3 Answers
How to schedule responses (based on player's input text) for text adventure game? 0 Answers
How does the new input system work? 1 Answer
My script for a "shield" function goes on/off constantly when it's supposed to be on 1 Answer
I am trying to create a leaning mechanic for an FPS game but I have one problem 1 Answer