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); }
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); }
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; } }