I’ve been working with the character blueprint, and all of the pre-built movement features, and I was wondering if there is a way to set a minimum movement speed for character movement? I have locomotion animations that are synced with a speed of 150 for walking, and 300 for jogging. I know how to set max movement speeds in the blueprint, and how to change them in-game, but I need to set a minimum movement speed, so that when a joystick axis on a controller is pushed just a little bit, The speed goes to 150, instead of anywhere between there and zero. If the character moves at a speed of 50 for example, my walk/strafe anims will not be synced with the floor movement. Its fine with a keyboard, because if W and S are on an axis for speed, pressing W would set the speed to the max, since it is a button with no in between values. I know I could use root motion now, but I would like to use the movement component since it can be replicated over a network for multi-player. I am not a programmer, and I don’t know a whole lot of blueprint, but I’m learning. Any help would be greatly appreciated!
Thanks in advance!
There are a couple of solutions here.
The first one, and perhaps the easiest, is to tell the walk/run blendspace to let X axis drive anim speed. This way analogue players get full freedom of speed but the animations look correct since they slow down when walk speed is slower. Setting this up may involve some trial and error though, and it only works if you want to allow the players to make a walk/run distinction as they move.
Alternately, you might try clamping the output of your InputAxis events (well, the better way is to make a vector from them and then clamp its length if it is nonzero, so the behavior is consistent at all angles of the left stick) so that the stick’s minimum nonzero value corresponds to whatever you want the minimum “stick pressed” to be.
For my game, for instance, I clamp the input vector and break it again to drive the Add Movement Input nodes, so that it can only have a length of 0 or 1. Controller users can move in full 360° but they can only have movement be “on” or “off”, with no walk-speed movement in between.
Hmm…I don’t think the first solution will work. Ive got a 2d blendspace with a lot of anims. The Y axis is driven by speed, and the X is direction from -180 to 180. The Y axis goes from 0 to 300, and all of my directional walking animations are at 150, with my jogging at 300. My Idle and Idle turns are at Y=0. So its a single blend space with multiple modes of movement. I’ve got Idle, Idle pivoting, Walking, Walk Strafing, Jogging, and Jog turning all in one. In my character blueprint, when I press a strafe button, My character faces in the direction of the camera and rotates with it. The max speed also changes to 150. This allows him to strafe in all directions while facing forward. When the button is not pressed, the max speed is 300 and he can walk and jog in all directions ( toward or away from the camera) with turning animations. It works well, and the feet stay in sync with ground movement until speed drops below 150. So, ideally, Id like to be able to have speed be 0, or 150 - 300 when hes not strafing, and only 0 or 150 when he is. I know its a bit confusing sorry about that. The main issue is when he is walking without strafing (Left stick pushed halfway in any direction) and the speed is half of 300 (150), and when I press the strafe button, He turns toward the camera but now halfway on the stick becomes 75, and not 150 which is my walk speed.
Regrettably there is no way to specify a “minimum speed”. The best you could do would be to clamp the input vector length to be between 0.5 and 1 (or 0 if no input) but even then that won’t cover slow acceleration perfectly, it would just mean that the lowest requestable acceleration value would be half of the max accel rate.
Or, you know, 0.25, or whatever acceleration value will get you to 150 speed fast enough to make your anims look right.
Yeah…Well now I’m thinking I could make my own movement component, or change around my animtree and have idle in a separate state.
Idle in a separate state won’t work; it will clamp your anims right but then at low movement speeds the capsule will just slide around in a stationary idle pose!
Rewriting the CMP would probably work if you’re willing to get your hands dirty, but I really do feel like clamping the input vector length will work.
Obviously there exists, for your character, some acceleration value that will take you from 0 to 150 quick enough that the anim blends right. It will take some experimentation, but clamping the vector to correspond to that value minimum if it’s above zero (with 1 being the upper bound of that range and also equivalent to your max accel rate) will definitely work.
And it will also probably make things feel smoother since it won’t lead to situations where the player bounces from 0 to 150 in an instant and then moves from 150 to 160 the next instant (which might be fairly jarring).
That makes sense, but what I’ve done now seems to work OK. I’ve simply added very slow walk anims, so even at a speed of 1, it looks pretty good.