Hello! I am doing a project in which a car is going in one direction in a circle, I don’t know how to make it so that when a person was driving in the wrong direction, he was shown some kind of sign! If someone knows - please help.

// Start is called before the first frame update
void Start()
{

    As = GetComponent<AudioSource>();
    rb = GetComponent<Rigidbody>();
}

// Update is called once per frame
void Update()
{
    playerUpdatePoint = Wv.transform.rotation;
    //count += 0.001;
    //Debug.Log(count);
    if (Wv.transform.rotation.y > 0 && Wv.transform.rotation.y < 180)
    {
        if (Wv.transform.rotation.y == -playerUpdatePoint.y)
        {
            GoToBack.SetActive(true);
        }
        else
        {
            GoToBack.SetActive(false);
        }
    }
    if  (Wv.transform.rotation.y < 0 && Wv.transform.rotation.y > -180)
    {
        if (-Wv.transform.rotation.y == playerUpdatePoint.y)
        {
            GoToBack.SetActive(true);
        }
        else
        {
            GoToBack.SetActive(false);
        }
    }
}

private void OnTriggerEnter(Collider collision)
{
    if(collision.tag == "BotCar")
    {
        //OnDeath();
        DeathMenu.SetActive(true);
        WpPatrol.MovementSpeed = 0f;
        
        As.enabled = false;
        rb.constraints= RigidbodyConstraints.FreezePositionZ | RigidbodyConstraints.FreezePositionX;

    }
}

public void OnDeath()
{
    //DeathMenu.SetActive(true);
}

}

Hi @frantsuzik10

Vector math can help you out to get directions of your moving car in circular path. Once you have info about your car direction you can perform your actions.

This thread might be helpful for you:-
https://forum.unity.com/threads/getting-the-direction-of-a-vector.2103/

"float tiltAroundZ = joystick.Horizontal * tiltAngle;
        float tiltAroundX = joystick.Vertical * tiltAngle;
Quaternion target = Quaternion.Euler(tiltAroundX, 0, tiltAroundZ);
transform.rotation = Quaternion.Slerp(transform.rotation, target,  Time.deltaTime * smooth);"

Thank You!