public void InvokeTriggerEnter(GameObject obj, FCollision collision) { if (onTriggerEnter.ContainsKey(obj)) { onTriggerEnter[obj]?.Invoke(collision); } }
protected void TriggerCollisionEnter(PhysCompoundCollider other) { if (other.IsValid) { collisionSet.Add(other); } FCollision collision = new FCollision() { Other = other.gameObject, OtherCollider = other, OtherRigidbody = other as PhysRigidbody }; if (other.IsTrigger || IsTrigger) { PhysicsEngine.EventManager.InvokeTriggerEnter(gameObject, collision); } else { PhysicsEngine.EventManager.InvokeCollisionEnter(gameObject, collision); } if (collision.OtherRigidbody == null) { other.RemoteRegisterCollision(this); collision = new FCollision() { Other = this.gameObject, OtherCollider = this, OtherRigidbody = this }; if (other.IsTrigger || IsTrigger) { PhysicsEngine.EventManager.InvokeTriggerEnter(other.gameObject, collision); } else { PhysicsEngine.EventManager.InvokeCollisionEnter(other.gameObject, collision); } } }
protected void TriggerCollisionExit(PhysCompoundCollider other) { collisionSet.Remove(other); FCollision collision = new FCollision() { Other = other.gameObject, OtherCollider = other, OtherRigidbody = other as PhysRigidbody }; if (other.IsTrigger || IsTrigger) { PhysicsEngine.EventManager.InvokeTriggerExit(gameObject, collision); } else { PhysicsEngine.EventManager.InvokeCollisionExit(gameObject, collision); } if (!(other is PhysRigidbody)) { other.RemoteUnregisterCollision(this); collision = new FCollision() { Other = this.gameObject, OtherCollider = this, OtherRigidbody = this }; if (other.IsTrigger || IsTrigger) { PhysicsEngine.EventManager.InvokeTriggerExit(other.gameObject, collision); } else { PhysicsEngine.EventManager.InvokeCollisionExit(other.gameObject, collision); } } }
protected virtual void FixedUpdate() { //TODO: May result in performance problems. But we have to iterate through a copy in order to withstand a possible deletion of a collider component. HashSet <PhysCompoundCollider> copy = new HashSet <PhysCompoundCollider>(collisionSet); foreach (PhysCompoundCollider other in copy) { FCollision coll = new FCollision() { Other = other.gameObject, OtherCollider = other, OtherRigidbody = other as PhysRigidbody }; if (IsTrigger || other.IsTrigger) { PhysicsEngine.EventManager.InvokeTriggerStay(this.gameObject, coll); } else { PhysicsEngine.EventManager.InvokeCollisionStay(this.gameObject, coll); } } }
private void CollisionStay(FCollision obj) { Debug.Log("Collision stay"); }
private void CollisionExit(FCollision obj) { Debug.Log("Collision exit"); }
private void CollisionEnter(FCollision obj) { Debug.Log("Collision enter"); }