Well, i need to freeze my X rotation, Y rotation and Z position after i’ve created my gameobject. But for some reason only the last constraint i wrote (the z position) gets freezed, even if i’ve told my script to freeze all three of them. Here’s my code.
public List<GameObject> Mobs = new List<GameObject>();
public GameObject Mob;
// Use this for initialization
void Start ()
{
Mob = GameObject.CreatePrimitive(PrimitiveType.Cube);
Mob.transform.localScale = new Vector3(1f, 1f, 1f);
Mob.AddComponent<Rigidbody>();
Mob.rigidbody.constraints = RigidbodyConstraints.FreezeRotationX;
Mob.rigidbody.constraints = RigidbodyConstraints.FreezeRotationY;
Mob.rigidbody.constraints = RigidbodyConstraints.FreezePositionZ;
Mob.AddComponent<Mob>();
Mobs.Add(Instantiate(Mob, this.transform.position, Quaternion.identity) as GameObject);
}
Any ideas? Thanks for reading.