I'm trying to lock the camera onto a projectile, and having trouble.
I have the camera assigned to an invisible sprite.
I can get this effect easily by Pinning the camera to the projectile On Creation, then moving the camera back after the projectile lands. But the problem with this is Pin is much too inaccurate and has noticeable lag when moving at high speed like this.
I can use Set Position to Another Object every frame to set the camera on top of the projectile while it's flying, but I don't know of a way to distinguish one instance of the object from another like On Creation allows, so when an earlier projectile is stuck in the ground it can't find the proper one to stick to.
I could probably add the camera behavior directly to the projectile, then create a secondary version of it with no camera behavior to replace it with after it lands, destroy the original camera after the the projectile is launched and respawn it after the projectile is replaced.
But I have some complex actions going on with the projectile and replicating it all on the replacement projectile would create some pretty messy and complicated events.
As one example, the projectile is a giant ballista bolt, and if an enemy is hit they get impaled and travel with it. I don't even know how I would re-pin that specific enemy to that specific bolt, because of my earlier issue of distinguishing one instance of an object from another without using something like On Collision or On Destroyed.
Does anyone know of a good way to do this?
I could use Pick Nth Instance to find the newest projectile I think, but I have no idea how to automatically acquire the newest one.
Edit: I tried using Pick Nth Instance with Object.Count to get the highest number, but I then realized I have no idea how Pick Nth Instance is supposed to actually "pick" an instance at all, and can't get it to work.