Search Unity

Question How to get father's animation?

Discussion in 'Animation' started by unity_408540137, Dec 10, 2022.

  1. unity_408540137

    unity_408540137

    Joined:
    Oct 23, 2022
    Posts:
    44
    I try to use two objects, one called father, and its child

    I put animator into father, and drag child into father hierarchy.

    The I drag my script into child, because I want to use child to control father's animation

    The following is my scripts in child"

    public class Controller : MonoBehaviour
    {
    // Start is called before the first frame update

    Animator ani;
    void Start()
    {

    ani = this.parent.GetComponent<Animator>();--->Is that correct? ""this"" indicates child?
    }

    // Update is called once per frame
    void Update()
    {

    }
    }