コード例 #1
0
ファイル: Track.cs プロジェクト: radiomonter/Tanki_X
        public bool UpdateSuspensionContacts(float dt, float updatePeriod)
        {
            this.numContacts            = 0;
            this.averageSurfaceVelocity = Vector3.zero;
            this.averageVelocity        = Vector3.zero;
            bool flag = true;

            for (int i = 0; i < this.rays.Length; i++)
            {
                SuspensionRay ray = this.rays[i];
                ray.Update(dt, updatePeriod);
                flag &= ray.hasCollision;
                if (ray.hasCollision)
                {
                    this.numContacts++;
                    this.averageSurfaceVelocity += ray.surfaceVelocity;
                    this.averageVelocity        += ray.velocity;
                }
            }
            if (!flag && (updatePeriod > 0f))
            {
                for (int j = 0; j < this.rays.Length; j++)
                {
                    this.rays[j].ResetContinuousRaycast();
                }
            }
            if (this.numContacts > 1)
            {
                this.averageSurfaceVelocity /= (float)this.numContacts;
                this.averageVelocity        /= (float)this.numContacts;
            }
            return(flag);
        }