/**
  * Creates an OniColliderTracker of the appropiate type.
  */
 protected override void CreateTracker()
 {
     if (unityCollider is SphereCollider)
     {
         tracker = new ObiSphereShapeTracker((SphereCollider)unityCollider);
     }
     else if (unityCollider is BoxCollider)
     {
         tracker = new ObiBoxShapeTracker((BoxCollider)unityCollider);
     }
     else if (unityCollider is CapsuleCollider)
     {
         tracker = new ObiCapsuleShapeTracker((CapsuleCollider)unityCollider);
     }
     else if (unityCollider is CharacterController)
     {
         tracker = new ObiCapsuleShapeTracker((CharacterController)unityCollider);
     }
     else if (unityCollider is TerrainCollider)
     {
         tracker = new ObiTerrainShapeTracker((TerrainCollider)unityCollider);
     }
     else if (unityCollider is MeshCollider)
     {
         tracker = new ObiMeshShapeTracker((MeshCollider)unityCollider);
     }
     else
     {
         Debug.LogWarning("Collider type not supported by Obi.");
     }
 }
Пример #2
0
        public ObiDistanceField distanceField; /**< Distance field used by this collider.*/

        /**
         * Creates an OniColliderTracker of the appropiate type.
         */
        protected override void CreateTracker()
        {
            if (tracker != null)
            {
                Oni.SetColliderShape(oniCollider, IntPtr.Zero);
                tracker.Destroy();
                tracker = null;
            }

            if (useDistanceFields)
            {
                tracker = new ObiDistanceFieldShapeTracker(distanceField);
            }
            else
            {
                if (sourceCollider is SphereCollider)
                {
                    tracker = new ObiSphereShapeTracker((SphereCollider)sourceCollider);
                }
                else if (sourceCollider is BoxCollider)
                {
                    tracker = new ObiBoxShapeTracker((BoxCollider)sourceCollider);
                }
                else if (sourceCollider is CapsuleCollider)
                {
                    tracker = new ObiCapsuleShapeTracker((CapsuleCollider)sourceCollider);
                }
                else if (sourceCollider is CharacterController)
                {
                    tracker = new ObiCapsuleShapeTracker((CharacterController)sourceCollider);
                }
                else if (sourceCollider is TerrainCollider)
                {
                    tracker = new ObiTerrainShapeTracker((TerrainCollider)sourceCollider, accurateContacts);
                }
                else if (sourceCollider is MeshCollider)
                {
                    tracker = new ObiMeshShapeTracker((MeshCollider)sourceCollider);
                }
                else
                {
                    Debug.LogWarning("Collider type not supported by Obi.");
                }
            }

            if (tracker != null)
            {
                Oni.SetColliderShape(oniCollider, tracker.OniShape);
            }
        }
Пример #3
0
        public ObiDistanceField distanceField; /**< Distance field used by this collider.*/

        /**
         * Creates an OniColliderTracker of the appropiate type.
         */
        protected override void CreateTracker()
        {
            if (tracker != null)
            {
                tracker.Destroy();
                tracker = null;
            }

            if (useDistanceFields)
            {
                tracker = new ObiDistanceFieldShapeTracker(this, sourceCollider, distanceField);
            }
            else
            {
                if (sourceCollider is SphereCollider)
                {
                    tracker = new ObiSphereShapeTracker(this, (SphereCollider)sourceCollider);
                }
                else if (sourceCollider is BoxCollider)
                {
                    tracker = new ObiBoxShapeTracker(this, (BoxCollider)sourceCollider);
                }
                else if (sourceCollider is CapsuleCollider)
                {
                    tracker = new ObiCapsuleShapeTracker(this, (CapsuleCollider)sourceCollider);
                }
                else if (sourceCollider is CharacterController)
                {
                    tracker = new ObiCapsuleShapeTracker((CharacterController)sourceCollider);
                }
                else if (sourceCollider is TerrainCollider)
                {
                    tracker = new ObiTerrainShapeTracker(this, (TerrainCollider)sourceCollider);
                }
                else if (sourceCollider is MeshCollider)
                {
                    tracker = new ObiMeshShapeTracker(this, (MeshCollider)sourceCollider);
                }
                else
                {
                    Debug.LogWarning("Collider type not supported by Obi.");
                }
            }
        }