OnCollisionExit(Collision)
OnCollisionExit is called when this collider/rigidbody has stopped touching another rigidbody/collider.
読み終わるまでの所要時間 1 分最終更新 10日前
Definition
- Type: Method
- Namespace: UnityEngine
OnCollisionExit()
public void OnCollisionExit(Collision collision)
Parameters
Remarks
OnCollisionExitcollisionOnCollisionExitcollisionNote: Collision events are only sent if one of the colliders also has a non-kinematic rigidbody attached. Collision events are sent to disabled MonoBehaviours, to allow enabling Behaviours in response to collisions.
If one of the objects involved in the collision is destroyed before they separate, is not called. If your logic depends on being called whenever contact ends, including when an object is destroyed, you need to implement additional logic, such as handling cleanup in MonoBehaviour.OnDestroy() or tracking destroyed objects manually.
OnCollisionExitOnCollisionExitOnCollisionExitExamples
using UnityEngine;using System.Collections;public class Example : MonoBehaviour{ void OnCollisionExit(Collision other) { print("No longer in contact with " + other.transform.name); }}