Editing a local variables position

I’m trying to cast a projectile (i’ll call it frostbolt) at an enemy object by changing the frostbolt’s velocity. The projectile itself works perfectly against a non-moving object. It gets a copy of the frostbolt from the ObjectPooler, sets it active and off it goes.

However, against a moving object I’m not sure how I could update the target’s position on the fly. Since this frostbolt is pooled and there could be multiple instances of it I’ve stored it in a local variable instead of global. I can’t think of a way to refer back to the exact frostbolt I want while it’s in the air to let it know it needs to move in a new direction (since I only had to run the method once in the first place).
I’m sure this problem has been solved multiple times but I couldn’t find the answer myself.


edit: as soon as i posted this i realised i might be able to put a script in the projectile’s prefab directly to update it on the fly. hopefully it works how i need it to.

On the frostbolt you could attach a script that moves the frostbolt to a target gameobject.
Then when grabbing the frostbolt from the objectpool you get the script component and set the target.
Something like that would probably work? If there is no target, it just flies off in the direction it was fired in.