void Update() { var state = gameObject.GetComponent <WeightEnemy>().CurrentState; var y = (originalPosition_.y - transform.localPosition.y) / moveLengthY; // Forecast an enemy's y-position because of servo delay. if (state == WeightEnemy.State.FALLING) { y += (transform.localPosition.y - groundPosition_.y) * EnemyFallingForecast; } else if (state == WeightEnemy.State.RISING) { y -= EnemyRisingForecast; } servo_.SetY(y); }