Preventing the player to move on "Z axis"

hello ,

i am making a Side scrolling game and i want my player to not move on the z axis …
if the z axis equal more or less then zero i want it to return to zero again :slight_smile:

Thanks :smiley:

I agree with DGArtistsInc, but the way you asked you could use a Mathf.clamp heres a link: http://unity3d.com/support/documentation/ScriptReference/Mathf.Clamp.html
or you could just use this

function Update () {
    if(transform.position.z >=.1 || transform.position.z <= -.1){
       transform.position.z = 0;
    }
}

its pretty simple you should look up some coding examples to get you off your feet.