Exemple #1
0
        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);
        }