Dear forummembers,
I am creating a simple top-down shooter where there is 1 player and several different kinds of enemies.
Both the player and the enemies shoot different kind of bullets.
All enemies are or inherit from the 'Enemy' class.
All bullets are or inherit from the 'bullet' class.
All enemies and the player have a variable called 'lives', all bullets have a variable called 'damage'.
On a collision I want to subtract the damage from the lives of wathever the bullet collided with. I could code this on the enemies and player, or on the bullets. Either way I need a variable from the object that scripted object is colliding with. The 'lives' var from the collider if I code it on the bullets. Or the 'damage' var from the collider if I code it on the enemies or player.
But as they are many different objects they have different scripts attached. How would I able to get a variable of the collider without knowing what the name of the script is that is attached to that collider?
Thanks very much for any help.
↧