Freeze rigid body rotation for a specific ammount of time

Hi,

I’m currently using the following to freeze the rotation of a game object when it is collided with:

rigidbody.freezeRotation = true;

This locks the rotation permanently, but that I need is to be able to set the amount of time the game object is frozen after a collision.

I was thinking of putting a yield WaitForSeconds command in and then

rigidbody.freezeRotation = false;

but it has to be written in C Sharp and WaitForSeconds isn’t really supported.

If there a way I could freeze the rotation for x.xx seconds in one line with C Sharp?

Thanks

Something like this should work

OnCollsionEnter(){
 StartCoroutine(FreezeIt());
}

IEnumerator FreezeIt(){
 rigidbody.freezeRotation = true;
 yield return new WaitForSeconds(5);
 rigidbody.freezeRotation = false;
}

Above is fine, or Use Invoke.

I’ll give that a try

Thanks guys!