How do I create a pickup that has a temporary effect?

I know how to create a few pickups that can give health, speed, armour and a few other things to the player. However I don’t know the best way to go about giving temporary buffs to the player that are based on time.

For example, using the Quickshot example video, that boosts the players speed, what’s the best way to turn this into a time based, temporary speed buff?

You could have a blueprint interface with a function “IncreaseSpeed”, inputs “Speed” and “Time” (Both Integer or float, depending on what you need).

You make your player character and your bueprint of your pickup both have this blueprint interface.
Make sure you have a spherical or cubic component around the pickup that will serve as a “pickup range”. If another actor overlapps with your pickup we can tell the actor what to do via the blueprint interface!

On the PickUp blueprint now you want to have the “OnActorBeginOverlap” event call the “IncreaseSpeed” via the “Interface Message”, the target should be the overlapping actor, set speed and time to whatever you desire.

Now on the character (the one that will end up overlapping the pickup) make an event “IncreaseSpeed” which will have the outputs speed and amount. Now you can access your actual characters speed variable (if you are using a character blueprint preset then there is a max walk speed, usually set to 375. Just add the given speed to 375).

Now every tick subtract delta seconds from the Time given via the interface. Once time <=0 set your speed back to 375 (Or whatever your speed used to be)!

Well think about how you do this for normal stats like Health or Armor.

You get the variable from the actor and increase or decrease it.

It’s honestly not that much different.

Everything needs a stat or a function you can call. As one way you could do your movementspeed example imagine the following:

You call a function in your PlayerCharacter. This one sets two variables. Time and Speed. You add Speed to your current movement speed and leave the time as is for now.

Then in you EventGraph you change a bool to now check for the timer and decrease your “Time” variable each Tick by “Delta Seconds”. Once it’s smaller or equal to 0 reduce your movementspeed by your “Speed” variable and you’re done.

Again this is only one way to do it and there might be better once but it should do the job :wink:

Thank you guys for the answers, it’s actually helped me figure it out by myself in regarding what to call. You were both right in saying it’s easy. To be honest I only added a delay!

Pickup

As you can see the pickup is casting to the player. Either player 0 or 1 (it’s a local splitscreen 2 player game)

Character Blueprint

The character Blueprint nodes are a little messy in the way I scattered it (Sorry!). What I’m doing is getting the character movement and calling out the walk speed and setting it with whatever number my variable (Boost Speed) contains.

However I don’t want the player using this awesome, crazy speed forever, so I’ve slapped on a delay for 5 seconds which then reverts it back to the original value (I put the original value in my own custom variable called Walk Speed).

The strings just give me a quick visual on if its worked or not.

So this in fact works very well for what I’m doing. It’s one of several ways to go about it.

Thank you guys once again for the help and advice :slight_smile: