Beispiel #1
0
        private void OnCollisionEnter(Collision collision)
        {
            //If we collide with the player, we invoke the OnCollidedHand event.
            if (collision.collider.CompareTag("Player"))
            {
                OnCollidedHand?.Invoke();
            }
            else
            {
                OnCollided?.Invoke();
            }

            //Any collisions disables the cube
            Disable();
        }
Beispiel #2
0
        protected virtual void Collided(Body otherBody, Vector2 collisionAxes, CollisionInfo <Body> hCollisionInfo, CollisionInfo <Body> vCollisionInfo)
        {
            OnCollided?.Invoke(otherBody, collisionAxes, hCollisionInfo, vCollisionInfo);

            if (Movement != null)
            {
                Movement.BodyCollided(otherBody, collisionAxes, hCollisionInfo, vCollisionInfo);

                if (otherBody.Tags.HasAny(Movement.CollisionTags))
                {
                    Movement.Collided(collisionAxes, hCollisionInfo, vCollisionInfo);
                }
            }

#if RENDER_COLLISION_CONTACT_POINTS
            _contactsToRender.AddRange(hCollisionInfo.Contacts);
            _contactsToRender.AddRange(vCollisionInfo.Contacts);
#endif
        }