Ejemplo n.º 1
0
        // Not called on parts where physicalSignificance = false. Check the parent part instead.
        public void OnCollisionStay(Collision c)
        {
            if (!scrapeSparks || _paused)
            {
                return;
            }

#if DEBUG
            if (useSpheres)
            {
                spheres[3].GetComponent <Renderer>().enabled = true;
                spheres[3].transform.position = c.contacts[0].point;
            }
#endif
            foreach (ContactPoint contactPoint in c.contacts)
            {
                // Contact points are from the previous frame. Add the velocity to get the correct position.
                // Only the parent part has a rigidbody, so use it for all adjustments.
                Vector3 point = Utils.PointToCurrentFrame(contactPoint.point, part);

                Part foundPart = GetCollidingPart(contactPoint);
                if (foundPart != null)
                {
                    CollisionFX cfx = foundPart.GetComponent <CollisionFX>();
                    if (cfx != null)
                    {
                        cfx.Scrape(foundPart, c.gameObject, c.transform, point, c.relativeVelocity.magnitude, c.collider.name, (contactPoint.thisCollider is WheelCollider));
                    }
                }
            }
        }