Download

Magnet! Endless Runner

Hey guys,

So I have completed the Endless Runner Tutorial and have added some extra bits for myself. However, for the life of me I cannot get a magnet power up to work. All I want is when the character gets the magnet power up, for 5 seconds after that, any coins the character passes will be drawn to them. I have tried many different things but still cannot wrap my head around it.

Any help would be much appreciated!!

Many thanks,
RykarnV

I recently did something like this when creating items that pull to my character like in Minecraft. Inside my Item actor, I created a function that fires on overlap, and sets a bool to true to be pulled. Then on the event tick, i used a branch and if it’s true, use move component to. This works and could probably be done in your character as well. I would just create a collision sphere and have it as wide as your running area.

If you use the search function on here you will find a post I already put up with my blueprint that does this. Probably under “endless runner magnet” or something similar

Here’s how I did something similar.

In the pickup blueprint, I added a capsule component and set up this code for the overlap…

&stc=1

IsMagneticPickup is an editable (and exposed on spawn) variable so you can turn this functionality on or off easily.

The timeline is a simple float track that goes from 0 to 1 over 10 seconds. I liked this to keep the pickup following you smoothly if you run away from it quickly.

Hope that helps.