void FixedUpdate() // 30 times per second, sense 1 time per second, decide 2 times per second { hp -= 0.005f; DecideTimer = grid.Decide(); SenseTimer = grid.Sense(); if (DecideTimer == 30) { Decide(); } if (SenseTimer == 15) { Sense(); } if (grid.ClosestWolf(this) > 2) { this.GetComponent <SpriteRenderer>().color = NormalColor; } if (sheepStates == _states.eating) { if (grid.SheepEating(this) == true) { hp += 0.25f; this.GetComponent <SpriteRenderer>().color = EatingColor; } else { this.GetComponent <SpriteRenderer>().color = NormalColor; Startimus(); } } if (hp > 20) { grid.AddSheep(currentSheepPos.x, currentSheepPos.y); hp = 5; } if (hp <= 0) { currentSheepPos = grid.ClosestTile(this); grid.AddSheepGrass(currentSheepPos.x, currentSheepPos.y, this); Destroy(gameObject); } if (sheepStates == _states.moving) { if (transform.position.x != newPos.x) { transform.position = Vector2.MoveTowards(transform.position, new Vector2(newPos.x, oldPos.y), 0.65f * Time.deltaTime); } if (transform.position.x == newPos.x) { transform.position = Vector2.MoveTowards(transform.position, new Vector2(newPos.x, newPos.y), 0.65f * Time.deltaTime); } } if (grid.SheepEaten(this) == true) { Instantiate(blood, transform.position, Quaternion.identity); Destroy(gameObject); } }