method of notifying when a creature is killed
I just need a script who describes the way you can say player kills an enemy. Or someone could explain me the logic of this. Thanks in advance.
Do you already have some code? Depending on your design, there can be a large number of different answers to this question ... Generally you could take a look at the observer-pattern.
Yep, as Chris suggests it depends on your design. I'd say go for events if you can't use something simple as this piece of code :
if(creature.health < 1) {
creature.$$anonymous$$ill();
Notify$$anonymous$$ill(creature);
}
Answer by SarperS · Jun 26, 2016 at 12:56 PM
Events is the way to go, here's a nice official tutorial from the Unity Tech http://unity3d.com/learn/tutorials/topics/scripting/events?playlist=17117
Sorry but I still dont understand. I wanna say in scripting that player kills a creature. Could be good saying in the creature's health script:
if(curHealth >= 1 && _playerDamage.isAttacking == true)
{
_player$$anonymous$$illedCreatureName == true;
}
And in the quest script:
if(_player$$anonymous$$illedCreatureName (i dont know how to say 6 times) && questIsActive == true)
{
questCompleted == true;
}
If it is correct can someone tell me how I can say the bool is true 6 times?