Get component multiple times

My game is an FPS in which enemies are spawned and the player kills them. In order for the player and the enemies to apply damage to each other, both need a script in which a GetComponent is used to access one another’s variables for health and damage etc. Since the enemies eventually are destroyed and new ones are spawned, I need a way to have the player’s script getcomponent again every time a new enemy is spawned.

So far, I have not figured this out. If anyone can help me then that would be greatly appreciated.

1 Answer

1

Why not have the newly spawning enemy hand over the relevant information to the player’s script. Whatever spawns the enemy can do that, or maybe from Start() on the enemy’s script itself.