// Update is called once per frame private void FixedUpdate() { // set scorpion position scorpionPosition = rb2d.position; x_velocity = rb2d.velocity.x; y_velocity = rb2d.velocity.y; // attack if hero is close else go to hero if (HeroWithinRange("attack")) { anim.SetTrigger("EnemyStanding"); Attack(); } else { // detect if hero stand on scorpion if (HeroWithinRange("hero on scorpion")) { anim.SetTrigger("EnemyStanding"); Invoke("UpperAttack", 0.5f); } warningAttackNr = 0; // follow hero if enemy see him if (HeroWithinRange("follow")) { enemyManager.SetOrderInLayer(-Mathf.RoundToInt((DistanceVector(ref heroManager.GetHeroPosition(), ref scorpionPosition).x * 10))); FollowHero(ref heroManager.GetHeroPosition(), ref scorpionPosition); } else { followHeroMode = false; anim.SetTrigger("EnemyStanding"); } } // set crust SetCrust(); }