動画はこちら
https://youtu.be/8T7Gy67bL6w
地面に下記スクリプトがアタッチされます。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class count : MonoBehaviour
{
//===== 変数定義エリア start =====
private int boundCount;
public Text boundCountText;
//===== 変数定義エリア end =====
//===== 初期処理 start =====
void Start()
{
}
//===== 初期処理 end =====
//===== 主処理 start =====
void Update()
{
}
//===== 主処理 end =====
//===== ボールがぶつかったときに加算される処理 =====
private void OnCollisionEnter(Collision collision)
{
boundCount++;
boundCountText.text = boundCount.ToString();
}
}