/**
         *  @brief Initializes internal properties based on whether there is a {@link FPCollider2D} attached.
         **/
        public void Initialize()
        {
            if (initialized)
            {
                return;
            }

            FPCollider = GetComponent <FPCollider2D>();
            if (transform.parent != null)
            {
                tsParent = transform.parent.GetComponent <FPTransform2D>();
            }

            if (!_serialized)
            {
                UpdateEditMode();
            }

            if (FPCollider != null)
            {
                if (FPCollider.IsBodyInitialized)
                {
                    FPCollider.Body.FPPosition    = _position + scaledCenter;
                    FPCollider.Body.FPOrientation = _rotation * FP.Deg2Rad;
                }
            }
            else
            {
                // StateTracker.AddTracking(this);
            }

            initialized = true;
        }
        internal void Update(GameObject otherGO, Physics2D.Contact c)
        {
            if (this.gameObject == null)
            {
                this.gameObject = otherGO;
                this.collider   = this.gameObject.GetComponent <FPCollider2D>();
                this.rigidbody  = this.gameObject.GetComponent <FPRigidBody2D>();
                this.transform  = this.collider.FPTransform;
            }

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

                FPVector2 normal;
                Physics2D.FixedArray2 <FPVector2> points;

                c.GetWorldManifold(out normal, out points);

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

                this.relativeVelocity = c.CalculateRelativeVelocity();
            }
        }
Exemplo n.º 3
0
        /**
         *  @brief Creates a new {@link FPRigidBody} when there is no one attached to this GameObject.
         **/
        protected override void OnAwake()
        {
            FPTransform = this.GetComponent <FPTransform2D>();
            FPRigidBody = this.GetComponent <FPRigidBody2D>();

            if (lossyScale == FPVector.one)
            {
                lossyScale = FPVector.Abs(transform.localScale.ToFPVector());
            }
        }