This may not be the ideal solution. The problem here is that End Overlap will fire whenever something has come-in and then gone. So if some other actor (Players, Bullets…)pass through the Target area, that event will fire.
You can make use of collision channels to avoid this issue. But I do not think thats the ideal solution here.
This is how I would try to do it:
I will create two Actors:
- CrateSpawner (Extended from actor with a sphere collision volume) ->this will replace target points
- SuperSpeedPickup (the same thing you have now)
CrateSpawner will be responsible for spawning the SuperSpeedPickup. He will have a variable called respawnDelay which will determine how much time to wait till a new Pickup is spawned. Another variable called ElapsedDelay will act as a counter which is set to 0 initially. A third variable of type Object’SuperSpeedPickup’ named ‘Pickup’ will hold a reference to the currently spawned Pickup.
In my tick event, I will check if the reference to ‘Pickup’ is valid. If it is dont do anything. Otherwsie I will see if the value of ElapsedDelay is greater than RespawnDelay. If it is, I will spawn the Pickup Actor and store a refenece in Pickup variable. I will also reset the ElapsedDelay to 0. If on the other hand the value of ElapsedDelay has not exceeded, then add the deltaSeconds to ElapsedDelay.
I will override the BeginOverlap event of CrateSpawner. I will check to see if the overlapped actor is a player, if yes, then check and make sure that the reference stored in Pickup is valid. If both pass, destroy the Pickup and apply the effect on the Player (this is entirely your logic).
And thats it.