- Home /
Question by
paco morales · Feb 18, 2013 at 10:44 PM ·
getaxis
How to put limits in Z?
Hello Everyone,
I'm trying to move one object with the mouse, now my script is working, but I want to put limits in Z, because if I keep moving my mouse or cursor the 3dbject vanish from the screen.
Also I did try to add another script sequence to disable the movement of my cursor in order to not affect my buttons while is moving my 3d Object.
Please any advice is more than welcome.
var movedownY = 0.0;
var sensitivityY = 0.1;
function Update(){
if (Input.GetAxis("Mouse Y")){
var v3T : Vector3 = Input.mousePosition;
v3T = Camera.main.ScreenToViewportPoint(v3T);
if (v3T.x > 0.90) return;
movedownY += Input.GetAxis("Mouse Y") * sensitivityY;
if (Input.GetAxis("Mouse Y") != 0){
transform.Translate(Vector3.forward * movedownY);
}
movedownY = 0.0;
}
}
Comment
You could allways clamp the Z axis of the object, but that might not be what you want...