Unity 5.0 Physics Freeze rotation not working

I’ve set freeze rotation on my objects to true, but for some reason whenever they bounce off a wall or finish moving they are rotating. I just recently upgraded my project from 4.3 to 5.0. Before I updated, the physics was working fine and I never had this problem. I’ve changed several settings, but I can’t seem to fix it.

Each of the objects is using a capsule collider, and they have rigidbodies set to interpolate and continuous dynamic with freeze rotation on for each axis.

Has anyone else run into this problem?

I resolve the problem this way

void FixedUpdate(){
Vector3 oldRot = transform.rotation.eulerAngles;
transform.rotation= Quaternion.Euler(oldRot.x, 90,oldRot.z);
(Fixed Y)

Janis I went ahead and got a substitute constraint script to work. My scripting issue was I was changing the transform in other places during FixedUpdate, so I had to move my changes into Update to constrain them.

It also let me set Min and Max rotations and allow for custom recovery speeds (so it turns back forward (quickly) instead of just locking down, it looks more realistic in the end).

Here is a copy of my code if it helps.

#pragma strict

private var baserot: Vector3;
var xreturnspeed: float;
var yreturnspeed: float;
var zreturnspeed: float;

var xmin : float;
var xmax : float;

function Start () {
//saves the initial rotation for use as the "home" rotation.
	baserot = transform.rotation.eulerAngles;
	print (baserot);

function Update () {
	//rotates back to home on the Y axis at yreturnspeed over deltaTime
	//I use this with a very fast return speed because I want minimal deviation on Y, you might want to set and min and max similar to what is in my Fixed Update.
	var wantedrotation = Vector3(transform.rotation.eulerAngles.x, baserot.y, transform.rotation.eulerAngles.z); 
 	transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.Euler(wantedrotation), Time.deltaTime * yreturnspeed);


function FixedUpdate () {
	//the rest is X constraint with min and max, I used this with a slower return because in other scripts I have rotation on X when moving.
	if(transform.rotation.x < xmin) {
		transform.rotation.x = xmin;
	else if (transform.rotation.x > xmax) {
		transform.rotation.x = xmax;

	var wantedrotation = Vector3(baserot.x, transform.rotation.eulerAngles.y, transform.rotation.eulerAngles.z); 
 	transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.Euler(wantedrotation), Time.deltaTime * xreturnspeed);

I had a same problem. So I fixed it with this code. And It rotate only y axis.

function FixedUpdate() {
GetComponent.().rotation.x = 0f;
GetComponent.().rotation.z = 0f;

We can also read from the constraints bits if they change in runtime (can be done like this) or if we want our artist/rigger/animator to be able to change the constraints from the editor:

byte bits = (byte)rigidbody.constraints;
if ((bits & (1 << 1)) != 0)
    Debug.Log("x position frozen");
if ((bits & (1 << 2)) != 0)
    Debug.Log("y position frozen");
if ((bits & (1 << 3)) != 0)
    Debug.Log("z position frozen");
if ((bits & (1 << 4)) != 0)
    Debug.Log("x rotation frozen");
if ((bits & (1 << 5)) != 0)
    Debug.Log("y rotation frozen");
if ((bits & (1 << 6)) != 0)
    Debug.Log("z rotation frozen");

We can use this information to make a hacky override to our objects localRotation:

// save startRotation during Start() or something

byte bits = (byte)rigidbody.constraints;
Quaternion frozenRotation= new Quaternion(
    (bits & (1 << 4)) != 0 ? startRotation.x : transform.localRotation.x,
    (bits & (1 << 5)) != 0 ? startRotation.y : transform.localRotation.y,
    (bits & (1 << 6)) != 0 ? startRotation.z : transform.localRotation.z,
transform.localRotation = frozenRotation;

Note: setting transform.localRotation.w as the w component will be slightly off, since that holds the total rotation magnitude before we clamped the rotation back to the start rotation… I think.

I am not 100% sure, but for me i changed the collider to a cube and the issue seems to be resolved, Has anyone tried this? even just for the lowest part collider of whatever your model is?