LoginSignup
0
0

More than 3 years have passed since last update.

地面でボールがバウンドした回数を表示する

Posted at

バウンド例.gif

動画はこちら
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();
    }
}

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0