void Awake() { _transform = GetComponent <Transform> (); _rigidbody = GetComponent <Rigidbody> (); if (_rigidbody == null) // if Rigidbody is missing { Debug.LogError("Rigidbody2D component missing from this gameobject"); } _animator = GetComponent <Animator>(); if (_animator == null) // if Animator is missing { Debug.LogError("Animator component missing from this gameobject"); } _audio = GetComponent <AudioSource>(); if (_audio == null) { // if AudioSource is missing Debug.LogWarning("AudioSource component missing from this gameobject. Adding one."); //let's just add the AudioSource component dynamically _audio = gameObject.AddComponent <AudioSource>(); } _moveTime = 0f; _moving = true; if (taskNo == 1) { dishManager = GameObject.FindGameObjectWithTag(managerTag).GetComponent <DishManager>(); } else if (taskNo == 2) { fishManager = GameObject.FindGameObjectWithTag(managerTag).GetComponent <FishManager>(); } granyAController = GameObject.Find("GranyA").GetComponent <GranyAController>(); }
private void Start() { dropinPotSound = GetComponent <AudioSource>(); granyAController = GameObject.Find("GranyA").GetComponent <GranyAController>(); }