I’m converting my code from the old input system to the new input system and used the character controller from the Unity starter assets and how it is set up to convert to the new input system. A sample of the code is below, copied from StarterAssetsInputs.cs and it works to expose a public variable and control the input. It is visible in the editor so I can tell what is happening. The problem is, that sometimes the boolean for the button change doesn’t change back to false, and stays true, and I’m not sure why.
It references an input action which is set to “button” with a “press and release” binding for a gamepad.
There are two action maps and maybe it gets stuck in the true position when it changes action maps but I can’t tell for sure.
It seems like this shouldn’t matter anyways because it should do the button press and release in one frame and not be interrupted.
Any ideas why it would not change back to false in the same frame? Or is there a better way to do this?
using UnityEngine;
using System.Collections.Generic;
using UnityEngine;
#if ENABLE_INPUT_SYSTEM
using UnityEngine.InputSystem;
using System.Collections;
#endif
namespace StarterAssets
{
public class deleteme : MonoBehaviour
{
public bool pressm;
#if ENABLE_INPUT_SYSTEM
public void OnPressM(InputValue button)
{
//pressx=button.isPressed;
PressMInput(button.isPressed);
}
//More of the same like the above goes here.
#endif
public void PressMInput(bool newPressMState)
{
pressm = newPressMState;
}
}
}