I use Unity to create a game. I have several animal enemies in the game.
I work on missions inside the game that you need to kill a random number of random animals, I already have this.
I have a problem with increasing the number of missions when you kill an animal.
I have a script (dead) sitting on every animal, when the animal dies, it calls a public function inside a dead script.
From a dead script, it should increase the int value in the "MissionHolder" script, where all animals have an int value, which increases when you kill the animal.
The problem is that I donβt know which animal kills when a player kills an animal, what I did:
public string Name; public MissionHolder missionHolder; public void Kill() { if (name == "Tiger") { missionHolder.Tiger += 1; } if (name == "Hyena") { missionHolder.Hyena += 1; } if (name == "Gorilla") { missionHolder.Gorilla += 1; } if (name == "Giraffe") { missionHolder.Giraffe += 1; } if (name == "Gazelle") { missionHolder.Gazelle += 1; }
and etc.
Now I call each animal its own name in a dead script, but it is not very effective.
Does anyone know a better way to do this?
performance c # unity3d
Dionysos sjaak
source share