【问题标题】:How I can make multiplayer in ranking system c# in unity我如何在统一的排名系统 c# 中制作多人游戏
【发布时间】:2022-01-06 07:42:21
【问题描述】:

我的代码没有错误但排名位置不正常

我如何改变我的项目。我想在游戏中制作RPS。

【问题讨论】:

  • 请提供一些代码来支持您的问题。

标签: position ranking scoring game-center-leaderboard


【解决方案1】:

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;
        }
    }             
}

【讨论】:

  • 您的答案可以通过额外的支持信息得到改进。请edit 添加更多详细信息,例如引用或文档,以便其他人可以确认您的答案是正确的。你可以找到更多关于如何写好答案的信息in the help center
猜你喜欢
  • 1970-01-01
  • 2018-03-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-03-15
相关资源
最近更新 更多