Пример #1
0
        // Update is called once per frame
        void FixedUpdate()
        {
            //gravity
            m_rigidbody.AddForce(Gravity.GetGravityAt(transform.position) * gravityMultiplier, ForceMode2D.Force);

            //Stand up only if not totally upside down
            float angle = Vector3.SignedAngle(Gravity.GetUpAt(transform.position), transform.up, Vector3.forward);

            if (Mathf.Abs(angle) < 120)
            {
                m_rigidbody.AddTorque(Mathf.Lerp(0, standUpTorque, Mathf.Abs(angle) / 90) * Mathf.Sign(-angle));
            }
        }