#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

# Euler Angles problem

The code for turning car going from down side(called south)

1. using System;
2. using UnityEngine;
3. [RequireComponent(typeof(MoveCar))]
4. public class NorthTurnRight : MonoBehaviour
5. {
6.    private Rigidbody rb;
7.    private float eulerAngleVelocity;
8.    private void Start()
9.    {
10.     rb = GetComponent<Rigidbody>();
11.    }
12.    private void FixedUpdate()
13.    {
14.     rightTurn();
15.    }
16.    private void OnEnable()
17.    {
18.     transform.GetChild(0).gameObject.SetActive(true);
19.    }
20.    void rightTurn()
21.    {
22.      float carRotation = Mathf.Floor(transform.eulerAngles.y);
23.      if(transform.localPosition.x > -20.5f && carRotation != 180f)
24.      {
25.        if(carRotation >= -176f && carRotation <= 184f)
26.        {
27.         transform.localRotation = Quaternion.Euler(new Vector3(0, 180f, 0));
28.          return;
29.        }
30.       eulerAngleVelocity = GetComponent<MoveCar>().speed *8.57f;
31.       Quaternion deltaRotation = Quaternion.Euler(new Vector3(0, eulerAngleVelocity, 0) * Time.fixedDeltaTime);
32.       rb.MoveRotation(rb.rotation * deltaRotation);
33.      }
34.    }
35. }

The code for turning car going from upside(called north)

Then moving to a problem:

https://vimeo.com/535931682

Talking to a code the car must turn (south one) from 90 to 180 degrees, but it reverses. Working cars are using the same type of script, but they don't have any problems. What is the problem?