【发布时间】:2022-01-06 07:42:21
【问题描述】:
我的代码没有错误但排名位置不正常
我如何改变我的项目。我想在游戏中制作RPS。
【问题讨论】:
-
请提供一些代码来支持您的问题。
标签: position ranking scoring game-center-leaderboard
我的代码没有错误但排名位置不正常
我如何改变我的项目。我想在游戏中制作RPS。
【问题讨论】:
标签: position ranking scoring game-center-leaderboard
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;
}
}
}
【讨论】: