ProjectStorms.ShipPartDestroy.OnTriggerEnter C# (CSharp) Method

OnTriggerEnter() public method

Called when a trigger enter begins to objects.
public OnTriggerEnter ( Collider a_otherCol ) : void
a_otherCol UnityEngine.Collider Other collider.
return void
        void OnTriggerEnter(Collider a_otherCol)
        {
            // Ignore losing parts to prisoners
            if (!a_otherCol.tag.Contains("Passengers"))
            {
                Rigidbody rbOther = a_otherCol.GetComponentInParent<Rigidbody>();
                if (rbOther != null)
                {
                    // Work out relative collision velocity
                    Vector3 offsetVel = (m_rb.velocity - rbOther.velocity);
                    float velDiffSqr = offsetVel.sqrMagnitude;

                    // Run on the other ship because OnTriggerEnter only allows us to get the other component, not our own collider
                    ShipPartDestroy scriptOther = a_otherCol.GetComponentInParent<ShipPartDestroy>();
                    if (scriptOther != null)
                    {
                        scriptOther.EvaluatePartCollision(a_otherCol, velDiffSqr);
                    }
                }
            }
        }