예제 #1
0
        private bool IsHit(TrackMarksBuilderComponent builder, TrackMarksComponent trackMarks, WheelData[] wheels, float hitDistance, out RaycastHit hit)
        {
            WheelData data = wheels[wheels.Length / 2];
            bool      flag = Physics.Raycast(data.position, -trackMarks.transform.up, out hit, hitDistance * 2f, TRACK_LAYER_MASK);

            if (flag)
            {
                RaycastHit hit2;
                if ((hit.distance >= (hitDistance * 1.5f)) && !this.CheckExtraContacts(builder, trackMarks, wheels, hitDistance))
                {
                    return(false);
                }
                float maxDistance = hit.distance + 0.1f;
                flag &= Physics.Raycast(data.position + (data.right * trackMarks.markTestShift), -trackMarks.transform.up, out hit2, maxDistance, TRACK_LAYER_MASK);
                if (flag)
                {
                    RaycastHit hit3;
                    flag      &= Physics.Raycast(data.position - (data.right * trackMarks.markTestShift), -trackMarks.transform.up, out hit3, maxDistance, TRACK_LAYER_MASK);
                    hit.normal = (hit3.normal + hit3.normal) / 2f;
                    hit.point  = (hit3.point + hit2.point) / 2f;
                }
            }
            return(flag);
        }
예제 #2
0
 private void CopyWheelDataFromTransforms(Transform src, ref WheelData dst)
 {
     dst.position = src.position;
     dst.right    = src.right;
 }