I’m new to Unity scripting so I’m not even sure I’m asking the right question. I have a script attached to an enemy character. When my player has died I want the enemy to stop playing the attacking animation. I other words, the enemy doesn’t know the player is dead. My solution would be to check the the state of the player’s death animation. If the player’s death animation parameter is set to true then stop attacking. For this I would need to find out the state of the player’s death animation. First, is my logic correct? If so, how do I do this? As I said, I’m new so try to be as simple as possible. Thanks!
If you’re just screwing around, have a field in the enemy into which you drag a reference to the player. Each frame have the enemy see if the player has died and stop attacking. It doesn’t scale but it proves your gameplay quick and dirty.
If you’re looking for a longer-term solution, you probably need to have some kind of “Find someone to attack” manager script (which could find the player, or another party member, or they might find a villager too, for instance), and then the enemy would call that to find his next victim. Using that reference, the enemy would attack the victim until it determined that victim has died and move onto the next victim.
There are lots of ways to write manager scripts. The simplest one simply has public references to the player, and you can extend it from there.
Thanks for the direction. Up to this point I have be just screwing around. Experiments just to see how things work. Make a terrain, create a drive script, create a third person character, collisions, etc. Now it’s time to put the elements together. I’ve heard of player manager scripts, I guess the same would be needed for enemies. Any suggestions on where to research writing manager scripts?