Best Way of Adjusting Player Walk Speed

Hey Everyone, just a quick question

I have a project which includes a player who has an inventory. What I want to do, is depending on the weight of the inventory, adjust the player walk speed.

What I wanted to try and find out, is would I do this in the Character BP from Input Axis Move Forward event as in the screenshot below:

Or would it be best to check and set the walk speed after the player picks up an item or drops one etc where the weight is modified.

The way in the screenshot is easiest as I only need to make one modification (which currently works), just not sure if performance is affected doing it this way. If I do the second method then it involves modifying each BP where the inventory weight is modified and is more work.

Or maybe i’m not thinking of any other solutions which someone might have.


Input Axis events fire every frame. So setting the walk speed as part of it means you end up running the check every frame regardless of whether it’s required or not. As a result, it would be better to set the walk speeds only when the inventory weight is modified.

Also on a side note, if you’re using an actor or a component to handle the inventory, then you can have the weight modification logic inside it. So no matter what item gets added or removed, the inventory blueprint can handle get the weight info from the item, then calculate the updated weight, and pass the new info to the player character. This will ensure that you won’t have to make changes to the blueprints of any of the items.

I figured this might be the case. Thanks. And yeah I have a component which handles the inventory so shouldn’t be too difficult. Thanks

I have implemented solution where I directly adjust the Max Walk Speed of the movement component to achieve this. I’m not certain it’s the best solution but it certainly seems to work fine.

Yeah it’s what that function was doing, however it was running on every frame, so I did what stormrage mentioned. I just needed to add the function to my inventory so when something was picked up, dropped, used ect, the check would be made and the walk speed in the movement component would be changed if need be. I was unnecessarily doing this on every frame before.

Can I get more clarification on this? I am new to UE4 and have an actor that also can get weighed down. The more weight, the slower the movement. My question is: Why is it called “Max Walk Speed” if we keep using it like “Current Walk Speed”? If I want to show a percentage of how much the weight is slowing me down… don’t I need a “Current” and a “Max” so that I can figure out the percentage? Everywhere I read tells me to lower the max when something affects the walk speed, and I don’t want to go around the system unless necessary as it has so much built in and tied to it already. Can someone help me with this - What is the best way to adjust current walk speed and maintain what the default max walk speed should be when unaffected temporarily?

There is no built-in functionality that alters the Walk Speed property of the Movement Component based on another variable. You’ll need to calculate it yourself.

You keep it all in your own variables. And there are many ways to calculate it; you probably already have a good idea regarding how it should work in your case.

Consider the following:

  • I’d call this event as soon as the weight of what the player is carrying changes, namely when they pick up / drop stuff
  • Max Weight / Current Weight are my stats, here we’re exceeding Max 3 times over
  • this particular division will result in the player slowing to 1/3 of My Max Walk Speed
  • My Max Walk Speed is also one of the player stat variables I’ve added
  • Once the effect of excess weight is calculated, we apply it to the movement component, which will dictate to what walking speed can the player accelerate

If you wanted to play with percentages:

For something a tad more comprehensive:

  • the division will produce values below 1 if we’re not exceeding weight, and will go above 1 if we do
  • the Map Range node will allow us to move with My Max Walk Speed for as long as we stay below 90% encumbrance.
  • exceeding 90% will linearly reduce the speed until we exceed by more than 200%, at which point we can no longer move. The Map Range translates 2 into 0.
  • we’re carrying 300% of our capacity, we can’t move

@packMule - very suitable user name for the topic.

1 Like