Exemplo n.º 1
0
        void Update()
        {
            if (drawShape)
            {
                DrawShape();
            }

            depenetrationShape.position = transform.position;

            for (int i = 0; i < detectionIterations; i++)
            {
                GetContacts(collisionPointsBuffer, checkOffset);
                if (collisionPointsBuffer.Count > 0)
                {
                    for (int j = 0; j < collisionPointsBuffer.Count; j++)
                    {
                        if (drawContacts)
                        {
                            ExtDebug.DrawPlane(collisionPointsBuffer[j].closestPointOnSurface, collisionPointsBuffer[j].interpolatedNormal, .5f, Color.cyan);
                        }
                    }
                }

                depenetrationShape.position += SphereCollisionDetect.Depenetrate(collisionPointsBuffer, depenetrationInterations);
            }
        }
Exemplo n.º 2
0
        void Update()
        {
            if (drawShape)
            {
                DrawShape();
            }

            GetContacts(collisionPointsBuffer);
            if (ignoreBehindPlane)
            {
                SphereCollisionDetect.CleanByIgnoreBehindPlane(collisionPointsBuffer);
            }

            if (collisionPointsBuffer.Count > 0)
            {
                for (int i = 0; i < collisionPointsBuffer.Count; i++)
                {
                    if (drawContacts)
                    {
                        ExtDebug.DrawPlane(collisionPointsBuffer[i].closestPointOnSurface, collisionPointsBuffer[i].interpolatedNormal, .25f, Color.magenta);
                        Debug.DrawLine(collisionPointsBuffer[i].detectionOrigin, collisionPointsBuffer[i].closestPointOnSurface, Color.red);
                        Debug.DrawRay(collisionPointsBuffer[i].closestPointOnSurface, collisionPointsBuffer[i].normal, Color.green);
                    }
                }
            }
        }
 void DrawGroundDebug(Vector3 hitPoint, Vector3 normal, float size, Color planeColor, Color rayColor)
 {
     if (infoDebug.drawGrounding)
     {
         ExtDebug.DrawPlane(hitPoint, normal, size, planeColor);
         Debug.DrawRay(hitPoint, normal, rayColor);
     }
 }
        float overrideYMovementConsistency;         //used to keep the position of the movement ray constant so we can properly see the movement consistency

        void DrawContactsDebug(List <SphereCollisionInfo> collisionPoints, float size, Color planeColor, Color rayColor)
        {
            if (infoDebug.drawContacts)
            {
                for (int i = 0; i < collisionPoints.Count; i++)
                {
                    ExtDebug.DrawPlane(collisionPoints[i].closestPointOnSurface, collisionPoints[i].interpolatedNormal, .5f, planeColor, infoDebug.drawContactsDuration);
                    Debug.DrawRay(collisionPoints[i].closestPointOnSurface, collisionPoints[i].normal, rayColor, infoDebug.drawContactsDuration);
                }
            }
        }
Exemplo n.º 5
0
        void OnCollisionStay(Collision collisionInfo)
        {
            foreach (ContactPoint contact in collisionInfo.contacts)
            {
                if (drawPhysXContacts)
                {
                    //I set the draw time to Time.fixedDeltaTime since OnCollisionStay is ran every FixedUpdate, which means there would be flickering if we dont keep the draw there long enough until it runs again.
                    ExtDebug.DrawPlane(contact.point, contact.normal, .5f, Color.yellow, Time.fixedDeltaTime);
                }

                if (drawPenetration)
                {
                    float seperation = (reversePenetration) ? -contact.separation : contact.separation;
                    ExtDebug.DrawPlane(contact.point + (contact.normal * seperation), contact.normal, .1f, Color.cyan, Time.fixedDeltaTime);
                }
            }
        }