0

my code have no error but ranking position is not working properly

how I change in my project. I want to make RPS in game.

1 Answers1

0

public int currentCheckPoint, lapCount;

public float distance;
private Vector3 checkPoint;

public float counter;
public int rank;
public GameObject panelcar;
public GameObject losepanel;
void Start()
{
    currentCheckPoint = 1;
    StartCoroutine(LevelFail());
}

// Update is called once per frame
void Update()
{
    CalculateDistance();
}
void CalculateDistance()
{
    distance = Vector3.Distance(transform.position, checkPoint);
    counter = lapCount * 1000 + currentCheckPoint * 100 + distance;
}

private void OnTriggerEnter(Collider other)
{
    if(other.tag == "CheckPoint")
    {
        currentCheckPoint = other.GetComponent<CurrentCheckPoint>().currentCheckPointNumber;
        checkPoint = GameObject.Find("CheckPoint" + currentCheckPoint).transform.position;
    }
    if(other.tag == "Finish")
    {
        if(gameObject.name == "Player")
        {
            panelcar.SetActive(true);
            Time.timeScale = 0f;
            AudioListener.volume = 0f;
        }            
        if (gameObject.name == "Red Car" || gameObject.name == "Orrange Car" || gameObject.name == "yellow Car" || gameObject.name == "Blue Car" || gameObject.name == "Tursh Car")
        {
            losepanel.SetActive(true);               
            Time.timeScale = 0f;
            AudioListener.volume = 0f;
        }
    }             
}
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jan 06 '22 at 13:03