I have a player that can swing a sword. I’ve got 2 scripts, 1 is a locomation script on the player, and the other a collider script on the sword that checks the collider tag is enemy and does something.
My enemy has animations and states, such as “dead”.
How would i go about triggering the “dead” state on the enemy from the attack script?
It doesn’t feel right to make “dead” a public function on the enemy. Is it ok to define a enemy.takeDamage(x) on my enemy and then call that in my swordAttack script?
Check Youtube for other tutorials about interfaces and working in Unity3D. It’s a pretty powerful combination.
But as always, I urge you to experiment a lot for yourself, just see what makes sense. Don’t get too complicated or tangled up early. Make a simple smack-skeletons kinda game, then add another enemy type and see how something like interfaces can help you, then refactor it.