SpriteFactory.SpriteCollider.OnCollisionExitSprite
C#: void OnCollisionExi_Sprite (SpriteFactory.SpriteCollider.CollisionData collisionData)
JS: function OnCollisionExitSprite (collisionData : SpriteFactory.SpriteCollider.CollisionData) : void
Description
Called when this collider/rigidbody has stopped touching another rigidbody/collider. This message is sent to all component siblings of the Sprite which owns this SpriteCollider.
The collisionData object contains information about the collision:
If the collision was between 3D colliders,
the collisionData.objectValue field contains a Collision object.
If the collision was between 2D colliders, the collisionData.objectValue field contains a Collision2D object.
In contrast to OnTriggerEnter, OnCollisionExit is passed the Collision class and not a Collider. The Collision class contains information about contact points, impact velocity etc. Note that collision events are only sent if one of the colliders also has a non-kinematic rigidbody attached.
Example:
C#
// Attach this script to the GameObject that contains your main Sprite component using UnityEngine; using System.Collections; using SpriteFactory; public class CollisionTest : MonoBehaviour { void OnCollisionExitSprite(SpriteFactory.SpriteCollider.CollisionData collisionData) { if(collisionData.spriteColliderName == "HitCollider") { // test collider name to determine which responded Collision collision = (Collision)collisionData.objectValue; // get the Collision object from collisionData Collider otherCollider = collision.collider; // get the other collider that collided with this collider Debug.Log(collisionData.spriteColliderName + " exited collision with " + otherCollider.name); } } }
JS
// Attach this script to the GameObject that contains your main Sprite component import SpriteFactory; function OnCollisionExitSprite(collisionData : SpriteFactory.SpriteCollider.CollisionData) : void { if(collisionData.spriteColliderName == "HitCollider") { // test collider name to determine which responded var collision : Collision = collisionData.objectValue; // get the Collision object from collisionData var otherCollider : Collider = collision.collider; // get the other collider that collided with this collider Debug.Log(collisionData.spriteColliderName + " exited collision with " + otherCollider.name); } }