How to create a MoveSpeed Slow status effect?

Hi, i’m working on a top down prototype and i have a few actions that affect my character’s movement speed, by directly “Setting” the MaxWalkSpeed inside the movement component of the character, my “Combat mode” for example:


The problem is, i want one of my Enemy AI’s to be able to cause a “Slow” on the movement speed of the character, but i didn’t want to directly set the the Max Walk Speed, because i imagine it would overwrite other actions such as my combat mode move speed, what i want is for the player’s speed to still change upon doing actions such as entering combat mode, but on top of the speed, i want the status effect to be applied, for example, cutting the movespeed by half, so if the character’s standard movespeed is 300 out of combat, and 200 in combat, i’d like it to be 150 out of combat, and 100 in combat, during the time where the “status effect” is applied, any pointers on how to approach this? Thanks!

Hey there @Windstride! So with all status effects I recommend having a system to house what effects are on any given character, and then if it’ something that effects stats, apply it as a modifier. For example, you can have a map of status effects and their severity applied to the player. When the attack hits you, you call a custom event that adds the Slow 3 status effect to the map and adds/subtracts the speed percentage from the movement modifier. Then when when the time for the status effect elapses, you remove the status effect from the map, and add the speed back to the movement modifier variable. The movement modifier is a float variable that is multiplied with your base movement speed to make an easy way for external effects to change the movement without directly setting your movement speed value.

So let’s say Slow 3 takes off 30% of your final movement speed. You would then subtract 0.3 from the movement modifier and it becomes 0.7. When multiplied against your base movement will output 70% of your current base movement speed.

Using this logic you could also move your combat speed slow down to either being a status, or even subtracting a flat rate before applying the status effects with the movement modifier.

1 Like

Hello there, thanks for the answer, this sounds more or less how i imagined it would work, but the part that i don’t really understand is how to add that Slow 3 status effect that you mention, can you elaborate on how i would do that? So i make sure that this slow is running as a modifier on top of my already existing movement speed changes and subtracting % of it.

You could add modifiers to an array, and then get the product of the entire array to add your speed.

Hi, how would i go about adding it to my speed though? Would i just connect the product of the array to an Add it to the Max Speed variable and then “Set Max Speed” with it? If so, wouldn’t that overwrite the Set Move Speed of other events, as mentioned above?

If you need to know what the default max speed is, you can store that in a variable or as data somewhere.

Rather than have many events set the move speed, you could have a single event for setting the move speed. Here you gather all of the possible influences and apply them.

So rather than setting the move speed directly, you call an event or function and pass in a new input for it. The input is either an update to some existing multiplier or a new multiplier altogether.

1 Like

Hmm, sounds like the smart solution, i don’t know if i’ll be smart enough to apply this in practise myself, but i’ll try

No worries! I’ll give you a demo:

First let’s create the variables and enumeration we’re going to need. (This is assuming your system wants to use flat values before the multiplier you can skip the flat addition if you don’t ever want flat values as well). Make a folder in the content browser to hold the enum and create one:
image

Then add some movement status effects:
image

Save that and you can close that window. Next open your base entity class (if you haven’t done inheritance or just want it only on your player character just open the player BP). and add these variables and remember to set your default percentage modifier to 1 instead of 0.

Next we’ll make an event or function that does something else when given a specific status effect (If you were doing this across many entities I’d probably make it an interface, or at minimum a different event but that’s a different tutorial). Here we also set a delay to remove the effect.

Then we update the movement speed. We do this every time a new movement speed modifier is added or removed through any means. The reason we call them only when there’s a change is so you don’t have to update the speed on tick when it’s not necessary. This isn’t 100% perfect, but shows off the basics of a system you can use.

Let me know if you have any questions.

1 Like

Thank you for such an elaborate answer and for the example! I’m not doing inheritance yet, but i implemented your example using a BPI, since my enemy AI is in a different BP and it’s who’s going to call the Apply Status Effect event upon attacking the player. It’s working, sort of, but still a few things i need to fix before it works fully as intended, i still have a few questions, hope it’s alright.

1 - I didn’t understand what the Flat Modifier variable is used for, it’s just there with a default value of 0, how/when should i use it?

2 - The slow effect is stacking upon getting hit by the slime/overlapping it multiple times before the timer runs out, what do you recommend to avoid this without compromising this system?

3 - The system is good for my needs, but i didn’t quite understand how i should integrate the other features that i already have that affect the movement speed, such as my combat mode:


For now, the movement slow works when i get hit or overlap the slime, but as soon as i trigger an event that sets the movespeed too, such as toggling the combat mode, or using the dodge roll, it overwrites the status effect system changes, how should i integrate those into this system, so the slow is always being applied on top of other features that also change move speed? Thanks for the attention!

  1. The flat modifier is actually meant to be used for your combat speed or any other flat changes that are calculated before the percentage modifier. It’s made so that you can say, add 100 to the base movement speed or take it away whenever. I didn’t make an event to work with it as example however, but you’d handle it nearly the same.

  2. Haha yeah that’s a side-effect of making a quick demo, I didn’t go into the nuances of a larger system like this. Determining how you want status effects to stack is part of extending this. This is a super minified version of my own overly complicated status effect system in my game. Originally I was just going to rip it out and try to send that over but it’s massive (and partially C++) so I opted to make a small demo for you instead. In my system, I check the map to see if a status effect of the same type is on, delete the old one from the map and reapply the effects. This only works because I use timer’s instead of delays, which in hindsight is likely what I should have recommended here.

  3. Apply the combat move speed as a flat modifier instead, so when you enter combat subtract 100 (or add -100) to the flat, then when you leave combat add 100 back. Basically any change to movement speed most come through those variables to be additive/multiplicative with the rest of the system.

There’s many ways to extend this type of system, but much of it will require a bit of changes to the demo, as it’s often better to have a function that applies status effects based on the effect’s data like a structure that gives off what it does, but that’s also getting a bit deeper.

1 Like

Ohh, thank you, that was very clarifying, i wasn’t seeing the full picture, so i can basically just have as many flat modifiers as i want there, as long as i set them accordingly.

Regarding the stacking, thanks, that gives me some direction though, i need to study the timer node a bit as well as these Add/Remove Map nodes, i need to understand them a little better before i can advance to coming up with a solution like yours in this regard.

No problem! Maps are a bit different from arrays and are a little odd in the way they are handled, so it takes a bit of practice. The map itself for the most part is just there to leave a list of what’s currently on your character so you can decide how to stack, or check for other effects, etc. I do recommend swapping over to timers, so you can also easily make a cleanse status effects setup as well. If you have any questions during the process feel free to ask, here’s the documentation on timers:

1 Like

Thanks a lot, i will be checking those, and potentially poking you in the future. :laughing:

1 Like