- Home /
Freezing movement on Z axis.
So i have this game im working on, its touch based TUIO game. Anyway, i have these 5 cubes in the same size, and i have them setup to the touch interface. My camera is facing the cubes straight forward. The cubes are all rigid bodies and they have a box collider.
In the rigid body have checked the Freeze rotation on the Z axis, and the freeze position on the Z axis. This should prevent them from moving back via the Z axis, at least that what i thought it would, but the bloody cubes keep changing position from Z axis 0 to maybe 3 and -2, which is very annoying since its a game where you place the cubes on top of eachother.
Anything that will prevent the movement at all or do i need to make a diffrent game?
Answer by Meltdown · Feb 24, 2011 at 10:55 AM
On your cube gameobject script, do something like this in the FixedUpdate...
void FixedUpdate()
{
rigidbody.transform.position.Z = 0; // Or whatever set location u want the cube to stay at.
}
Looks right, except the capital Z should just be a normal z. :)