Download

Can an action mapping input be used in a state transition to change states?

Hi. I’m using a Third Person Blueprint project.
Using the “Jump” action mapping as an example - when the input is pressed the Jump function is called (see image).

What I don’t quite get is how to invoke a different state eg. “Crouch” using an action map for crouch eg. the “Shift” key.
i have the animation for crouch and I have created a new state and the animation has been inserted into that state.

But the “Jump” node function comes is predefined by Unreal and I may be wrong but i’m assuming in the definition of this function it causes the transition to the JumpStart state.

I just wasn’t sure how to go from hitting the shift key to a new “crouch” state. Can I put the key press in the state transition?

Thanks.

What you want is a bool set once you hit the crouch key, then communicate that to the AnimBP. For this you can setup a simple Interface, add a function with a bool variable. Add that Interface to your character. Then you call that function with target AnimBP. Inside the AnimBP you add a Event MyInterfaceFunction and set a bool here too. Now when the bool is set the player should switch the state to crouch.

To prvent conflicts with jump, you add a bool check to your jump input key logic, to only jump when crouch is not true, in case you want this. If you want to be able to jump, you simply connect a path from the crouch state to the JumpStart. (IsCrouching? And IsJumping? or IsInAir?)

I hope that is clear enough, if not I can post some screenshots later.