public override void OnStateEnter() { base.OnStateEnter(); destiny = null; bb.SetWormInvulnerable(); //Set origin and destiny GameObject playerGO = rsc.enemyMng.SelectPlayerRandom(); if (playerGO != null) { PlayerController player = playerGO.GetComponent <PlayerController>(); destiny = player.GetNearestHexagon(); if (destiny != null) { head.animator.SetBool("Bite", true); speed = (headTrf.position - destiny.transform.position).magnitude / bb.AboveAttackSettingsPhase.jumpDuration; bb.CalculateParabola(headTrf.position, destiny.transform.position); head.agent.enabled = false; rotation = 0f; destinyInRange = false; //Calculate start point and prior point currentX = bb.GetJumpXGivenY(0, false); Vector3 startPosition = bb.GetJumpPositionGivenY(0, false); headTrf.position = startPosition; lastPosition = bb.GetJumpPositionGivenX(currentX); float fakeNextX = currentX + Time.deltaTime * 2; Vector3 nextPosition = bb.GetJumpPositionGivenX(fakeNextX); initialRotation = Quaternion.LookRotation(nextPosition - startPosition, headTrf.up); bb.isHeadOverground = true; head.attackWarningSoundFx.Play(); destiny.WormAboveAttackWarning(); subState = SubState.WARNING_PLAYER; } } }