I’ll split this post up in two parts, logic and animation, to try to help you both arbopa and Juice-Tin.
For implementing jumping and crouching in C++, CharacterMovementComponent has this already built-in and customizable, link to documentation. For example it has functions Jump(), Crouch() and UnCrouch(), IsMovingOnGround(), IsCrouching() etc prepared. Jump will give you upward velocity as you would expect, and you can tweak the strength by setting the CharacterMovementComponent’s JumpZVelocity value. Similarly crouch/uncrouch toggles your character’s collision capsule height (your camera will be lower since it’s a child of the capsule) and max movement speed. Again it has properties so you can adjust what those heights are. Be sure to check out the documentation and check the character movement component in blueprints, using blueprint here will help you explore the features.
Proning is not supported by CharacterMovementComponent, but you could use crouching for this with different values, for example:
- When crouching, set the CharacterMovementComponent to crouching height A, max speed A and call Crouch()
- When proning, set the CharacterMovementComponent to crouching height B (lower), max speed B (again lower) and call Crouch()
As for passing variables to the animation blueprint, you have to realize that an animation blueprint has two graphs, the anim graph and the event graph, with shared variables. In the event graph there is an “animation update” event node that fires every frame that allows you to update your animation variables. You can for example create booleans IsJumping, IsCrouching, IsProning in your anim BP, set them in the event graph and then read them in the anim graph. Your event graph can simply try to cast the anim BP’s controlled to a character and then call the character movement component’s IsMovingOnGround() and IsCrouching() functions. To differentiate between crouching and proning, you’ll need to store whether you are proning in your character class and then read it.