Ejemplo n.º 1
0
        /// <summary>
        ///  Create a raycast
        /// </summary>
        /// <param name="origin">The origin of the raycast</param>
        /// <param name="direction">The direction of the raycast</param>
        /// <param name="distance">max distance</param>
        /// <param name="mask">mask</param>
        /// <param name="offset">raycast offset</param>
        /// <returns>The hits value</returns>
        public static UCPhysicsHitsArray RaycastAll(Vector3 origin, Vector3 direction, float distance, int mask, float offset)
        {
            UCPhysicsHit hit;

            hits = new UCPhysicsHitsArray();
            ray  = new Ray(origin, direction);

            for (int i = 0; i < physicsObjects.Count; i++)
            {
                currentPObject = physicsObjects[i];

                if (Vector3.Distance(origin, currentPObject.transform.position) <= distance)
                {
                    if (currentPObject.Raycast(ray, out hit, mask))
                    {
                        if (hit.distance <= distance && hit.distance >= offset)
                        {
                            hits.AddToList(hit);
                        }
                    }
                }
            }

            if (UnityEngine.Physics.Raycast(origin, direction, out rayHit, distance))
            {
                if (rayHit.transform.GetComponent <UCPhysicsObject>() != null)
                {
                    hit = new UCPhysicsHit();
                    hit.Convert(rayHit);

                    hits.AddToList(hit);
                }
            }

            return(hits);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Remove a physics object from the physics simulation
 /// </summary>
 /// <param name="pObject">the object you want to remove</param>
 public static void RemovePhysicsObject(UCPhysicsObject pObject)
 {
     physicsObjects.Remove(pObject);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Add a physics object to the physics simulation
 /// </summary>
 /// <param name="pObject">the object you want to add</param>
 public static void AddPhysicsObject(UCPhysicsObject pObject)
 {
     physicsObjects.Add(pObject);
 }