using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BaozhaTest : MonoBehaviour
{
public GameObject prefab;
private float timer;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
timer += Time.deltaTime;
Debug.Log("Update");
}
//发生碰撞
private void OnCollisionEnter(Collision collision)
{
Debug.Log("发生碰撞");
prefab = Instantiate(prefab,transform.position,Quaternion.identity);
Destroy(gameObject);
}
//持续碰撞
private void OnCollisionStay(Collision collision)
{
Debug.Log("持续碰撞");
}
//结束碰撞
private void OnCollisionExit(Collision collision)
{
Debug.Log("结束碰撞");
}
}
unity碰撞监听检测demo
最新推荐文章于 2024-08-24 15:52:22 发布