我正努力让球员接触到一个名为" ballInAir"它减少了屏幕右上角的生命计数。它不起作用。这是代码:
using UnityEngine;
using UnityEngine.UI;
public class livesScript : MonoBehaviour {
public Text livesText;
public float lives;
// Use this for initialization
void Start () {
livesText = GameObject.FindWithTag("lives").GetComponent<Text>();
lives = 4;
}
// Update is called once per frame
void Update () {
livesText.text = "Lives: " + lives;
}
void OnCollisionEnter(Collision bol)
{
if (bol.gameObject.name == "ballInAir")
{
lives = lives - 1;
}
}
}