예제 #1
0
        internal void Update(GameObject otherGO, Physics2D.Contact c)
        {
            if (this.gameObject == null)
            {
                this.gameObject = otherGO;
                this.collider   = this.gameObject.GetComponent <TSCollider2D>();
                this.rigidbody  = this.gameObject.GetComponent <TSRigidBody2D>();
                this.transform  = this.collider.tsTransform;
            }

            if (c != null)
            {
                if (contacts[0] == null)
                {
                    contacts[0] = new TSContactPoint2D();
                }

                TSVector2 normal;
                Physics2D.FixedArray2 <TSVector2> points;

                c.GetWorldManifold(out normal, out points);

                contacts[0].normal = normal;
                contacts[0].point  = points[0];

                this.relativeVelocity = c.CalculateRelativeVelocity();
            }
        }
        internal void Update(GameObject i_OtherGO, Physics2D.Contact i_Contact)
        {
            gameObject = i_OtherGO;

            if (i_OtherGO != null)
            {
                collider  = i_OtherGO.GetComponent <TSCollider2D>();
                rigidbody = i_OtherGO.GetComponent <TSRigidBody2D>();
                transform = i_OtherGO.GetComponent <TSTransform2D>();
            }
            else
            {
                collider  = null;
                rigidbody = null;
                transform = null;
            }

            if (i_Contact != null)
            {
                if (contacts[0] == null)
                {
                    contacts[0] = new TSContactPoint2D();
                }

                TSVector2 normal;
                Physics2D.FixedArray2 <TSVector2> points;

                i_Contact.GetWorldManifold(out normal, out points);

                contacts[0].normal = normal;
                contacts[0].point  = points[0];

                relativeVelocity = i_Contact.CalculateRelativeVelocity();
            }
            else
            {
                relativeVelocity = TSVector2.zero;

                if (contacts[0] != null)
                {
                    contacts[0].normal = TSVector2.zero;
                    contacts[0].point  = TSVector2.zero;
                }
            }
        }