This script is attached to a game object and handles collision events.

The script includes a reference to a collisionPanel game object, which is used to display collision information.

In the Start() method, the script sets the rigidbody's isKinematic property to true, making the object's movement static. It also sets the collider's isTrigger property to true, making it a trigger collider.

The OnTriggerEnter() method is called when the object collides with another collider. If the other collider has a tag of "cube", the method returns without doing anything. Otherwise, it sets the CollisionText.Instance.str_CollisionText property to a string containing the names of the two colliding objects. It then calls the CollisionText.Instance.UpdateCollisionText() method to update the collision information in the UI. Finally, it sets the collisionPanel game object to active, making it visible.

public class OnCollision MonoBehaviour public GameObject collisionPanel;定义信息提示框 void Start Rigidbody rb = GetComponentRigidbody; 将刚体的运动类型设置为静态 rbisKinematic = true;

原文地址: http://www.cveoy.top/t/topic/i0n5 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录