I need to temporary restrict player’s control of the character, for stagger, cutscenes or whatever. But after some test I noticed that Input system’s methods for it just have no effect at all.
I pass input through events and use code generation feature to manage actions. So my disable functions look like this:
public void EnableControls(bool enable)
{
if(enable)
{
customClassField.ActionMap.Enable();
}
else
{
customClassField.ActionMap.Disable();
}
}
public void BanCertainActions(bool ban)
{
if(restrict)
{
customClassField.ActionMap.Action1.Disable();
customClassField.ActionMap.Action2.Disable();
customClassField.ActionMap.Action3.Disable();
}
else
{
customClassField.ActionMap.Action1.Enable();
customClassField.ActionMap.Action2.Enable();
customClassField.ActionMap.Action3.Enable();
}
}
And they were used like
public IEnumerator UncontrolledMove()
{
//whatever stuff it does
EnableControls(false);
yield return reqiredTime;
//whatever else happens here
EnableControls(true);
}
It did everything except disabling controls, and when this method was called by whatever input action I laid my eyes upon in the script it still did nothing. Where is the problem? Can it be in some conditions I didn’t mention here?
P.S. Separate methods for enabling and disabling look cumbersome.