Question by
Squinshee · May 27, 2018 at 02:37 PM ·
rigidbody2dangularvelocity
Rigidbody2D angular velocity is zero after I set it to a float that's not zero
Vector2 point2Target = (Vector2)target.transform.position - rb.position;
point2Target.Normalize();
float rotateAmount = Vector3.Cross(point2Target, transform.right).z;
float angularVelocity = turningSpeed * rotateAmount;
rb.angularVelocity = angularVelocity;
rb.velocity = transform.right * speed;
The above code is what I'm trying to execute. When I Debug.Log() the value of my angularVelocity float, it prints out a non-zero number. However, when I Debug.Log() the value of rb.angularVelocity after setting it to the float, it prints out 0. I have used this exact same code on a previous project and it worked fine. I have even mimicked the settings for the Rigidbody2D in the editor to match, and still the rb.angularVelocity is always 0. I'm not sure what I'm doing wrong here.
I really appreciate the help. Thanks!
Comment