Cant end the magnet effect of magnet powerup

I implemented magnet powerup for my endless runner game and made it work with the timeline function and it works flawlessly thanks to all the help guides present on the forums <3 Just this one thing is what I am not able to implement. The coins are attracted towards the player after the player picks up the magnet and it keeps on going forever even on a level restart. One thing is interesting that if I set the magnet time to 1 or 2 seconds the magnet works without any issues (I used the delay function for this). Anything above 2 seconds and the attraction keeps on going forever. Any help??

  1. those pics are really bad, way too far zoomed out to really make anything out
  2. your “has magnet” boolean is in the game instance so it would persist through levels at whatever value it had been given, if you want it to reset between levels store that variable on a player character or something that won’t persist level to level
  3. how long is the timeline? maybe that is an issue with why it works for certain “delay” values and not others. Screen shot the timeline graph editor along with better screen shots of what you already posted and we will go from there

Sorry for the bad pics, here are the pics including the timeline, and I think there is maybe some problem with the timeline function. Feeling kinda dumb as i know the problem is really minor but I just cant turn my head around it

Please can anyone help me with this?

What do you mean by “level restart”? Do you mean you hit escape and left the “play in editor” mode? Or are you still “in game” when you “restart” the level? Also, how big is this “magnet box/magnet floor”? Could the player be overlapping this multiple times?

Also, try printing the boolean “has magnet” after each “set” in the “magnet floor BP”. So pull the boolean from the game instance reference and “print string”. Make sure it is actually being turned on and off.

Level Restart is a console command which restarts my level. i paired it with delay so restarts after the delay. I am still in game when I restart the level. The magnet box is big enough that the player can overlap it multiple times. I made the function that will only activate once HasMagnet boolean is true. I tried print screen function before but not with HasMagnet, well definitely check it and reply as soon as possible.

Game instance doesn’t reset on level start; the game instance is specifically there so you can carry data between levels. Hence why you bool doesn’t get reset either. If you need to reset that bool on level restart, you have to reset it by hand before you restart the level.

Is there any reason you are doing all of this in the game instance by the way? Why not have the magnet functionality in the character itself? It seems rather counter intuitive.

I am thinking that when I update the game instance variable after the delay when the magnet is picked, the boolean value stored in the gameinstance change accordingly. The restart problem is there as you suggest with the game instance and I know that, but atleast the magnet must stop after a particular time i.e after the delay is over the boolean must be changed to false. My problem here is the value of the gameinstance dosent update if the delay is given more than 2 seconds. This means that the magnet goes on forever and I dont know why the value of the gameinstance is not getting updated on a delay value of more than 2 seconds.