private void OnTriggerEnter(Collider other) { GameObject throughObject = other.gameObject; int playerID = FindInfoByScene.Instance.GetPlayerID(throughObject.transform.parent.name); Debug.Log("プレイヤー" + playerID + "チェックポイント通過"); CheckPointCount cpCount = throughObject.GetComponent <CheckPointCount>(); int checkPointCnt = cpCount.GetNowThroughCheckPointNum(); Debug.Log("第" + (checkPointCnt + 1) + "チェックポイント"); Debug.Log("通過数:" + checkPointCnt); if (throughObject.tag == "RacingCar") { if (!_isThrough[playerID]) { if (gameObject.name == cpCount.GetNextCPName()) { // ゴール通過すると_checkPointCntが0に戻るのでここで特にmax時のif処理を書く必要はない Debug.Log("次チェックポイント:" + $"cp{(checkPointCnt + 2)}"); Debug.Log(gameObject.name); cpCount.CountCheckPoint(); _isThrough[playerID] = true; } } cpCount.LastThroughCheckPoint(this.name); } }
private void OnTriggerEnter(Collider other) { GameObject throughObject = other.gameObject; int playerID = FindInfoByScene.Instance.GetPlayerID(throughObject.transform.parent.name); Debug.Log("プレイヤー" + playerID + "チェックポイント通過"); CheckPointCount cpCount = throughObject.GetComponent <CheckPointCount>(); int checkPointCnt = cpCount.GetNowThroughCheckPointNum(); if (throughObject.tag == "RacingCar") { if (!_isThrough[playerID]) { if (cpType == CPType.StartOtherRoot || (cpType == CPType.OtherRoot && gameObject.name == cpCount.GetNextCPName())) { Debug.Log("別ルートcp通過"); // orチェックポイントのナンバー+1を次のチェックポイントとする int thisCPName = int.Parse(gameObject.name.Trim("or".ToCharArray())); Debug.Log($"次チェックポイント:or{(thisCPName + 1)}"); Debug.Log(gameObject.name); cpCount.CountCheckPoint($"or{(thisCPName + 1)}"); } else { Debug.Log("別ルート最終cp通過"); Debug.Log($"次チェックポイント:or{cp.name}"); Debug.Log(gameObject.name); cpCount.CountCheckPoint(cp.name); } _isThrough[playerID] = true; } cpCount.LastThroughCheckPoint(this.name); } }