I have a very simple input system using the old Unity input. For example I move a camera like this in update:
//Movement controls
if (Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.UpArrow))
{
newPosition += (adjustedForward * movementSpeed);
}
if (Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.DownArrow))
{
newPosition += (adjustedForward * -movementSpeed);
}
if (Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.RightArrow))
{
newPosition += (transform.right * movementSpeed);
}
if (Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.LeftArrow))
{
newPosition += (transform.right * -movementSpeed);
}
From all tutorials and materials I find it seems the new input system is mainly used with events, which does not fit my scenario.
How can I use the new Input system to simply check if “W” is being held like I do above? I tried input.World.CameraLeft.IsPressed() and input.World.CameraLeft.WasPressedThisFrame() that is bound to “W” with Action type button, but it doesnt work.
EDIT: Turns out another binding higher in the list was overriding it. But is this how your intended to perform this type of logic with the new Input System? I just made this up since everyone else uses events. Is this OK or is it creating a ton of garbage or something else I should be aware of?
New code:
//Movement controls
if (InputManager.Input.Gameplay.Up.IsPressed())
{
newPosition += (adjustedForward * movementSpeed);
}
if (InputManager.Input.Gameplay.Down.IsPressed())
{
newPosition += (adjustedForward * -movementSpeed);
}
if (InputManager.Input.Gameplay.Right.IsPressed())
{
newPosition += (transform.right * movementSpeed);
}
if (InputManager.Input.Gameplay.Left.IsPressed())
{
newPosition += (transform.right * -movementSpeed);
}