void OnTriggerEnter2D(Collider2D other) { if (other.tag.Equals("thePlayer") || other.tag.Equals("fishFood")) { if (anim != null) { if (eating) { timer -= Time.fixedDeltaTime; if (timer < 0) { MoveRandom move = gameObject.GetComponentInParent <MoveRandom>(); //move.movementEnabled = true; // Destroy(other.gameObject); eating = false; anim.ResetTrigger("eating"); } } else { eating = true; MoveRandom move = gameObject.GetComponentInParent <MoveRandom>(); move.movementEnabled = false; anim.SetTrigger("eating"); timer = 1; other.gameObject.GetComponent <FishInTheSeaDieScript>().Die(timer); } } } else { //Debug.Log("No Collision"); } }
public override void Start() { rb = GetComponent<Rigidbody>(); maxSpeed = 5.0f; maxDistance = 5.0f; energy = 1000; currentState = new MoveRandom(); }
// Use this for initialization void Start() { move = GetComponent <MoveRandom>(); }
private void Awake() { followDirection = GetComponent <FollowDirection>(); moveRandom = GetComponent <MoveRandom>(); }