Testable equivalent to UnityEngine.RaycastHit.
Esempio n. 1
0
        public bool Raycast(Vector3 origin, Vector3 direction, out Uniject.RaycastHit hitinfo, float distance, int layerMask)
        {
            UnityEngine.RaycastHit unityHit = new UnityEngine.RaycastHit();
            bool result = UnityEngine.Physics.Raycast(origin.ToUnity(), direction.ToUnity(), out unityHit, distance, layerMask);

            if (result)
            {
                IGameObject testable = null;
                var         bridge   = unityHit.collider.gameObject.GetComponent <UnityBridgeComponent>();
                if (null != bridge)
                {
                    testable = bridge.GameObject;
                }

                hitinfo = new RaycastHit(unityHit.point.ToUniject(),
                                         unityHit.normal.ToUniject(),
                                         unityHit.barycentricCoordinate.ToUniject(),
                                         unityHit.distance,
                                         unityHit.triangleIndex,
                                         unityHit.textureCoord.ToUniject(),
                                         unityHit.textureCoord2.ToUniject(),
                                         unityHit.lightmapCoord.ToUniject(),
                                         testable,
                                         unityHit.collider.ToUniject());
            }
            else
            {
                hitinfo = new RaycastHit();
            }

            return(result);
        }
Esempio n. 2
0
        public bool Raycast(Vector3 origin, Vector3 direction, out Uniject.RaycastHit hitinfo, float distance, int layerMask)
        {
            UnityEngine.RaycastHit unityHit = new UnityEngine.RaycastHit();
            bool result = UnityEngine.Physics.Raycast(origin, direction, out unityHit, distance, layerMask);

            if (result)
            {
                TestableGameObject    testable = null;
                UnityGameObjectBridge bridge   = unityHit.collider.gameObject.GetComponent <UnityGameObjectBridge>();
                if (null != bridge)
                {
                    testable = bridge.wrapping;
                }

                hitinfo = new RaycastHit(unityHit.point,
                                         unityHit.normal,
                                         unityHit.barycentricCoordinate,
                                         unityHit.distance,
                                         unityHit.triangleIndex,
                                         unityHit.textureCoord,
                                         unityHit.textureCoord2,
                                         unityHit.lightmapCoord,
                                         testable,
                                         unityHit.collider);
            }
            else
            {
                hitinfo = new RaycastHit();
            }

            return(result);
        }
Esempio n. 3
0
 public override void Update()
 {
     RaycastHit hit = new RaycastHit();
     if (physics.Raycast(Obj.transform.Position, Obj.transform.Forward, out hit, float.MaxValue, mask)) {
         sphere.obj.transform.Position = Obj.transform.Position + Obj.transform.Forward * hit.distance;
     }
 }