Movement issue with TryStartAbility on Aim ability

Michal Trněný

New member
Hello,

I want the player to have active the Aim ability when specific conditions are met. For simplicity, right now the condition is that you click once with the RMB and you stay in Aim forever.

C#:
    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.Mouse1))
        {
            var characterLocomotion = gameObject.GetComponent<UltimateCharacterLocomotion>();
            var aimAbility = characterLocomotion.GetAbility<Aim>();
            bool success = characterLocomotion.TryStartAbility(aimAbility, false, false);
        }
    }


Both Start type and Stop type is set to MANUAL. The Aim goes and stays ACTIVE, this part works well. But strangely, my character is not able to strafe sideways anymore. Whatever WASD key I am pressing, he is just moving forward.


However, everything works when I configure such scenario directly in inspector - If I remove my custom script and set the Start type to BUTTON DOWN, everything works as expected - my player is able to do strafing.


I am using this asset the 2nd day, so probably I overlooked something. Do you have any suggestion why those behaviours are different?

Thank you in advance
 
You may want to check if the Aim state is being enabled when starting the Aim ability manually like this. To manually set the Aim state, you would use:

StateManager.SetState(gameObject, "Aim", true);
 
Top