Sprite Factory

ReadMe
Release Notes
Overview
Using the Editor
Upgrading

Concepts
Sprites
Master Sprites
Sprite Groups
Colliders
Locators
Material Sets
SpriteUpdater
SpriteCamera

Advanced
Working in Multiple Projects

Classes
Runtime Classes

Videos
Overview
Creating Sprites
Sprite Inspector
Frame Events
Collision System
Locator System
Material Sets

Links
Sprite Factory Site
Web Documentation
Support
Contact

SpriteFactory.SpriteCollider.OnCollisionStaySprite

C#: void OnCollisionStaySprite (SpriteFactory.SpriteCollider.CollisionData collisionData)
JS: function OnCollisionStaySprite (collisionData : SpriteFactory.SpriteCollider.CollisionData) : void

Description
Called once per frame for every collider/rigidbody that is touching 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, OnCollisionStay 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 OnCollisionStaySprite(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 + " continued colliding with " + otherCollider.name);
       }
   }
}

JS

// Attach this script to the GameObject that contains your main Sprite component
import SpriteFactory;

function OnCollisionStaySprite(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 + " continued colliding with " + otherCollider.name);
    }
}