angularVelocity is always zero when using MoveRotation

I’m working with a rigidbody and need to use its angular velocity. But when using a MoveRotation method on it, its angularVelocity property always stays at zero. However, if I set rigidbody.isKinematic to true, angularVelocity begins to calculate correctly…

I wonder if that’s as it has to be, and if so, how can I calculate angularVelocity by myself with not kinematic rigidbodies?

Here is my script, which I use with a rigidbody:

using UnityEngine;
using System.Collections;

public class C_PlayerController : MonoBehaviour {
	
	private Rigidbody myRigid;
	private Vector3 cursorPosition;
	private Quaternion targetRotation;
	
    void Awake () {
        myRigid = GetComponent<Rigidbody>();
    }
	
	void Update () {
		cursorPosition = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, C_CameraController.currentDistance));
		cursorPosition.y = 5;
		targetRotation = Quaternion.Slerp(myRigid.rotation, Quaternion.LookRotation(cursorPosition - myRigid.position), Time.deltaTime * 2);
	}
	
	void FixedUpdate () {
		myRigid.MoveRotation(targetRotation);
		myRigid.AddForce(-myRigid.transform.forward * Vector3.Distance(myRigid.position, cursorPosition), ForceMode.Acceleration);
		
		print(myRigid.angularVelocity);
	}
	
}

What I’m trying to do there is making the rigidbody to “look” at the mouse cursor and follow it, while checking its angularVelocity (which stays at zero, if isKinematic is false).

So, as it appears to be, the only “fair” way to do rotation with rigidbody (and then be able to get its angularVelocity property) is to add force to it. I was able to make it look at the mouse cursor with this code (inside FixUpdate function):

if (myTransform.rotation.y != targetRotation.y) {
	if (targetRotation.eulerAngles.y - myTransform.rotation.eulerAngles.y > 180) 
		myRigid.AddTorque(0, (targetRotation.eulerAngles.y - myTransform.rotation.eulerAngles.y - 360), 0, ForceMode.Acceleration);
	else if (targetRotation.eulerAngles.y - myTransform.rotation.eulerAngles.y < -180) 
		myRigid.AddTorque(0, (targetRotation.eulerAngles.y - myTransform.rotation.eulerAngles.y + 360), 0, ForceMode.Acceleration);
	else myRigid.AddTorque(0, (targetRotation.eulerAngles.y - myTransform.rotation.eulerAngles.y), 0, ForceMode.Acceleration);
}

Thanks to ZoomDomain for hints :slight_smile: