コード例 #1
0
ファイル: TeleportArc.cs プロジェクト: tiare/UnityViveSetup
        //-------------------------------------------------
        private float FindProjectileCollision(out RaycastHit hitInfo)
        {
            float timeStep         = arcDuration / segmentCount;
            float segmentStartTime = 0.0f;

            hitInfo = new RaycastHit();

            Vector3 segmentStartPos = GetArcPositionAtTime(segmentStartTime);

            for (int i = 0; i < segmentCount; ++i)
            {
                float   segmentEndTime = segmentStartTime + timeStep;
                Vector3 segmentEndPos  = GetArcPositionAtTime(segmentEndTime);

                if (Physics.Linecast(segmentStartPos, segmentEndPos, out hitInfo, traceLayerMask))
                {
                    if (hitInfo.collider.GetComponent <IgnoreTeleportTrace>() == null)
                    {
                        Util.DrawCross(hitInfo.point, Color.red, 0.5f);
                        float segmentDistance = Vector3.Distance(segmentStartPos, segmentEndPos);
                        float hitTime         = segmentStartTime + (timeStep * (hitInfo.distance / segmentDistance));
                        return(hitTime);
                    }
                }

                segmentStartTime = segmentEndTime;
                segmentStartPos  = segmentEndPos;
            }

            return(float.MaxValue);
        }
コード例 #2
0
        // Token: 0x0600221C RID: 8732 RVA: 0x000A9918 File Offset: 0x000A7B18
        private float FindProjectileCollision(out RaycastHit hitInfo)
        {
            float num  = this.arcDuration / (float)this.segmentCount;
            float num2 = 0f;

            hitInfo = default(RaycastHit);
            Vector3 vector = this.GetArcPositionAtTime(num2);

            for (int i = 0; i < this.segmentCount; i++)
            {
                float   num3 = num2 + num;
                Vector3 arcPositionAtTime = this.GetArcPositionAtTime(num3);
                if (Physics.Linecast(vector, arcPositionAtTime, out hitInfo, this.traceLayerMask) && hitInfo.collider.GetComponent <IgnoreTeleportTrace>() == null)
                {
                    Util.DrawCross(hitInfo.point, Color.red, 0.5f);
                    float num4 = Vector3.Distance(vector, arcPositionAtTime);
                    return(num2 + num * (hitInfo.distance / num4));
                }
                num2   = num3;
                vector = arcPositionAtTime;
            }
            return(float.MaxValue);
        }