I want to know how you would call a function from a parent object via a script. A melee system object witch has the script that calls the animations on its child (the sword). i want the sword to call my function StopPlaying so that i will stop the swing after it has once. but i cant see the function in the animator. How would i do this?
You can access the parent object using transform.parent. Then get the Melee system component and call “StopPlaying”. Stop playing must be public in order for it to be visible to other scripts.
Or you could send a message to the parent like this:
When you send a message to a game object the named method is called on all of its components so if you have any other scripts attached with methods of the same name they’ll get called too.