Character Movement

Hi, would be cool if I could get some help with the basics of implementing a standard character movement system.

What I don’t understand is:

  • there are several bool-variables and functions related to jumping and crouching… which ones should I use, and in what order?
  • how should I deal with different speeds (run, walk, sprint)? Inside the movement component, under “Walk”, there is only a value for walk speed and one for crouch speed.
  1. The order should not matter, but depends on what you want to achieve. Also note that it’s an example project. There are several ways to implement the stuff shown in the ThirdPerson Example project (which i assume you refer to).

  2. Walkspeed is found under the CharacterMovement component. And in case you want your character to run you set the variable “Max Walk Speed” to a suitable running speed (like 600 or something) and in case you want your character to walk, set it to something like (200). This should however be matched up with whatever you setup inside your blendspace for movement. Hope that helps you out.

  1. Well, I am not actually referring to any particular example. I just want to avoid re-inventing the wheel when it’s already implemented… And it seems to me there is already a fully functional “jumping- & crouching logic” there, I just haven’t found an explanation what values to set and what functions to call. There are so many… Just to name some from “Character”: bPressedJump, CanJump(), CheckJumpInput(), ClearJumpInput(), IsJumping(), Jump(), OnJumped()… and then there are more inside the movement component (wantsToJump, DoJump() …) - and with crouching it is the same.

  2. Actually, this is how I’m doing it right now. But I thought it was more of a workaround, not a clean solution… The anim blueprint is already using character speed for blending. So, I don’t have to worry about writing custom movement modes or anything then?

I should probably ask more precisely…

I guess the way it’s meant to be done (and please correct me if I’m wrong) is to call Character::Jump() on pressing the jump-key and StopJumping() when the jump-key gets released. And for crouching: call Character::Crouch() on pressing the crouch-key and UnCrouch() on releasing it.

I did this and now I want to get the character’s jumping/crouching status when updating my Animation-Instance (or Blueprint), set the corresponding bool variables and have the state machine start the jumping/crouching state, so the correct animation gets played.

I am calling Character::IsJumping() (or IsJumpProvidingForce()) and checking Character::bIsCrouched for this, but it seems both values stay false, even though jumping adds a force to the character…

Yes correct with the jump logic. Check the isfalling status.

About 2) its the way i would do it

Hi again. I think I’ve got the crouching part right now, but I’m not sure how to use IsFalling() to trigger a jump animation. IsJumpProvidingForce() probably isn’t going to work (always false), unless I use a JumpKeyMaxHoldTime greater zero. But I don’t think I want to do that. So, what else could I use to distinguish between jumping and falling? I mean I wouldn’t want to trigger a jump animation when a character walks off an edge.

Of course, I could bind playing the animation directly to the input-event. But that would just be another (potentially flawed) workaround, would require a lot of “checks” to verify that the jump is actually going to happen, and more replicated network variables or function calls.

ah, you are making this networked… i didn’t know.

In any case, you should be able to use Jump(). I haven’t personally tried to use the other two you mention. When you walk off a ledge, IsFalling() is gonna be true. If you need to have a separate animation for when you trigger a jump by a control-action, then you should set a corresponding bool that the animation graph can use to determine which animation to play.