Hello, I have here a simple XP collecting set of events. When the XP objects are under “PlayerMagnet” (in this case 200 pixels) from Player, they home towards the Player. All of that is nice and good and working great. When the XP bar fills up i have it set to time scale 0 to pause the game so you can pick an upgrade. That also works fine.
However, all the XP objects that are within the 200 pixel range of the Player but not yet touching the Player vanish the moment the game pauses. After unpausing they are not accounted for in the XP bar. I don’t understand why that is. Any help is appreciated.
The projectile only needs to be locked onto once. Something weird happens when you lock the target when the time scale is set to zero.
I tested your events, it behaved the same way as you said. I then moved the linking part within a for each object with an at the beginning and the objects paused when the time scale was 0.
My objects were created in the editor. If you create them at runtime then just link the object right after it gets added.
The lock function links the object and restarts a timer. My guess is that when the timer is reset while the time scale is zero the elapsed time remains at zero which messes up the move function calculations. Normally, the timer would only be zero for 1 frame until reset. Multiplying and dividing by 0 can cause formulas to fail.
I’ve moved the Lock action on the condition to when an enemy dies and it started working, cheers.
Though now there’s another odd thing happening. If the XP object is within the 200 pixel range when it appears, it moves towards the player in an accelerating fashion as it should, but if I leave it behind and collect the XP later, it appears to be going at max speed from the start.
I don’t quite understand why since i left the homing the same way as above with the condition that it has to be within the player range
The expansion is starting the “__HomingProjectile_Lifetime” timer within the “LockOnTarget” action. I have never touched any extension yet, but I do think that you can change them inside your own project for your own needs. So just moving that timer from the “LockOnTarget” action to a new action, that you create yourself, might do the trick. Don’t forget to call this action only once (while the “MoveTowardsTarget” action needs to be called every frame).
I recommend to always check the expansion code. It teaches you how things function inside. If you actually want to learn something its also great to write your own algorithm and use extensions only as a reference for your own code. There is always different ways of doing things and you might just need to do things slightly different for your project - but if you made it yourself you know all the ins and outs of what you are doing.
And homing is fairly easy
EDIT:
Another solution without touching the expansion could be to call the “LockOnTarget” action not after an enemy dies, but as you want the object to start moving (what you originally aimed for). I am not certain, how well it works, if you use this without a “repeat for each” event, as you cannot use trigger once inside those.
(Also try setting lifetime to 0, as this will disable the lifetime algorithm)