- Home /
Question by
TrojanFM · Jan 30, 2012 at 01:50 AM ·
side-scrolling
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 :)
Thanks :D
Comment
why dont you just set the characters position on the z to 0 then set the controls to only move on the x and y axis, thats ussually how a side scroller works
Best Answer
Answer by IMTRIGGERHAPPY9 · Jan 30, 2012 at 02:13 AM
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.