/// <summary> /// Determines the next action based on a random number and the turnProbability /// </summary> private void DetermineNextAction() { float rand = Random.value; if (rand < turnProbability) { status = CraneStatus.TURNING; targetRotation = new Vector3(0, Random.Range(0, 359), 0); } }
/// <summary> /// Turns the top part towards the target rotation /// </summary> private void TurnTop() { craneTop.localRotation = Quaternion.RotateTowards( craneTop.localRotation, Quaternion.Euler(targetRotation), Time.deltaTime * turnSpeed ); float delta = craneTop.localEulerAngles.y - targetRotation.y; if (Mathf.Abs(delta) < 0.1f) { status = CraneStatus.IDLE; } }