Announcement

Collapse
No announcement yet.

Best Way of Adjusting Player Walk Speed

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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:

    Click image for larger version

Name:	Movement.jpg
Views:	47
Size:	123.3 KB
ID:	1675641

    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.

    Thanks.

    #2
    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.
    Last edited by Stormrage256; 10-20-2019, 01:59 AM.
    Wave Spawning System | Tower Defense Starter Kit | Grid Creation Systems

    Comment


      #3
      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

      Comment


        #4
        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.

        Comment


          #5
          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.

          Comment

          Working...
          X