Ejemplo n.º 1
0
        //Checks if 2 colliders are intersecting and will run resolve if they are
        public void DetectCollision(Rigid_Body body1, Rigid_Body body2)
        {
            //1st collider in detection
            Base_Collider col1 = body1.Collider;
            //2nd collider in detection
            Base_Collider col2 = body2.Collider;

            CollisionInfo collision = new CollisionInfo();

            //Check what type of collision check needs to happen
            if (col1.Collider_Type == ColliderType.AABB && col2.Collider_Type == ColliderType.AABB)
            {
                collision = AABBvsAABB((AABB_Collider)col1, (AABB_Collider)col2);
            }
            else if (col1.Collider_Type == ColliderType.CIRCLE && col2.Collider_Type == ColliderType.CIRCLE)
            {
                collision = CIRCLEvsCIRCLE((Circle_Collider)col1, (Circle_Collider)col2);
            }
            else if (col1.Collider_Type == ColliderType.CIRCLE && col2.Collider_Type == ColliderType.AABB)
            {
                collision = CIRCLEvsAABB((Circle_Collider)col1, (AABB_Collider)col2, false);
            }
            else if (col1.Collider_Type == ColliderType.AABB && col2.Collider_Type == ColliderType.CIRCLE)
            {
                collision = CIRCLEvsAABB((Circle_Collider)col2, (AABB_Collider)col1, true);
            }

            if (collision.hit)
            {
                ResolveCollision(collision, body1, body2);
            }
        }
Ejemplo n.º 2
0
 //initialise delegate to avoid null reference
 public void Empty(Base_Collider rhs, CollisionInfo colInfo)
 {
 }