C# locking z position to 0

Hi, I’m trying to make a Smash Bros like game, and I wanted to ask how I would go about making sure that the objects do not have a Z other then 0.

Attach a Rigidbody and you can freeze the position and rotation on the Z

Or:

Vector3 rotation = transform.localEulerAngles;
Rotation.z = 0;
transform.localEulerAngles = rotation.

Do the same for position.

I’m sorry, I’ve been trying to figure out how to do things for your first suggested method with no success. Would you please elaborate on it?

Your second suggestion sounds interesting too, but I don’t really understand what you mean by “do the same for position.”

edit–
Nevermind I got it!

Great! :slight_smile:

For the first, the image should show enough. That should prevent the object from moving on that axis.

1710170--107641--lockinplace.png