using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Collisiotest : MonoBehaviour {
private Renderer fuck;
// Use this for initialization
void Start () {
fuck = GetComponent<Renderer>();
}
// Update is called once per frame
void Update () {
}
void OnCollisionEnter(Collision c)
{
c.gameObject.GetComponent<Renderer>().material.color = Color.red;
Debug.Log("fuck1");
fuck.material.color = Color.red;
}
void OnCollisionExit(Collision c)
{
c.gameObject.GetComponent<Renderer>().material.color = Color.yellow;
//fuck.material.color = Color.red;
Debug.Log("fuck2");
}
}
需要装刚体/碰撞体组件,明天再仔细研究一波
unity3D 碰撞检测例子代码
最新推荐文章于 2025-03-30 11:31:27 发布