Hello @D0GMA17 ,
You can do this by gradually reducing the Character’s Max Walk Speed property.
To do that, first create a Custom Event called SpeedReduction, then search for the Set Timer by Event node with the Looping option enabled. This node is used to automatically execute an event every certain amount of time. Instead of manually calling a function or using Event Tick, the timer takes care of executing the event you assign to it repeatedly. In this case, with the timer set to 1, the event will execute every second, so the Character’s speed will be reduced once per second.
Then, from the Event pin of the Set Timer by Event node, create another Custom Event and name it ApplySpeedReduction, which will handle the speed reduction logic. Inside this event, get the Character Movement component and from its pin get Max Walk Speed. Subtract the amount you want the speed to be reduced by; in this example it is 50. This means that every time the timer executes, the Character’s current speed will be reduced by 50.
Connect the result of that subtraction to the Value pin of a Clamp (Float) node. What this node does is limit the value within a specific range. The Min value will be the minimum speed the Character can be reduced to, while the Max value will be the initial speed. In this example, the initial speed is 600, which is the Character’s default value. This prevents the speed from continuing to decrease indefinitely or reaching negative values.
Then, create another Character Movement node and search for Set Max Walk Speed. Connect the Return Value from the Clamp to the Max Walk Speed pin so the speed is updated using the Clamp’s value. After that, connect the execution output of ApplySpeedReduction to this node so the speed is reduced every time the timer executes.
From the Return Value of the Set Timer by Event node, select Promote to Variable and name it InvalidateSpeedReductionTimer. This is used to store a reference to the timer you just created. Without that reference, you would not be able to stop that timer later from another Blueprint.
For the power-up, first create a new Blueprint Actor. In the Content Browser, right-click, select Blueprint Class, choose Actor, and give it a name, for example BP_SpeedPowerUp.
Then open it and, in the Components tab, click Add and add a Box Collision component. This Box Collision will be used to detect when the Character overlaps with the power-up. You can also disable Hidden in Game on the Box Collision so its activation range is visible while testing.
then use the On Component Begin Overlap event. From the Other Actor pin, get your Character; in this example I am using BP_ThirdPersonCharacter. From the As BP_ThirdPersonCharacter node, get the InvalidateSpeedReductionTimer variable and connect it to a Clear and Invalidate Timer by Handle node. This will stop the timer that was reducing the Character’s speed so it does not continue running in the background.
also from the As BP_ThirdPersonCharacter node, get the Character Movement component and use a Set Max Walk Speed node to restore the speed to its normal value. As mentioned before, in this example the original speed is 600.
To test it in the BP_ThirdPersonCharacter, you can use the E key and call the SpeedReduction event, or use it from Event Begin Play so it executes at the start. To see how the speed is being reduced, you can use the Max Walk Speed node with a Print String on Event Tick, and you will see that the speed keeps decreasing until it reaches 50, and then gets restored when the power-up is collected.
This way, the Character’s speed will gradually decrease over time, and when the power-up is collected it will immediately return to its normal speed.
Hope it helps!