Hi. So I’ve a 2d top down space shooter with player, friendly, and enemy fighters zipping around. I have two types of bullets (prefabs). They’re identical copies of each other except for the coloring. One type is used by friendlies, one by enemies.
The bullets are all pooled and recycled, so are just setActive when a ship fires them.
How do I get the bullet to know WHO fired it, because I need to set kills of the player and each of his allies, yet they all use the same bullets. Same situation with the enemies.
I was thinking something like OnEnable, I do some sort of circular raycast (or a straight one aimed behind) to find the nearest game object, because that MUST be the one who fired it, in theory. I just don’t know enough about this area to succeed.
Can anyone provide a sample code, or even a simpler, more efficient solution to the problem?
Thanks a mil
-Kevin