Hi there, I would just like to move my camera in Y everytime I slide ( every time I press right click ) and put back my camera position at his original position
Sorry for the question Im still a newbie…
var originalPosition : Vector3;
function Update ()
{
if(Input.GetMouseButton(1))
transform.Translate(0,-moveSpeed,0);
else if (transform.position.y < originalPosition.y)
transform.Translate(0,moveSpeed,0);
}
this is the simplest way I can write this… Oh yeah, this script would be attached to the camera. If you want a smoother movement though, you would use a Lerp:
var originalHeight : float;
var minimumAllowableHeight : float;
var moveSpeed : float = 1;
function Update ()
{
if(Input.GetMouseButton(1))
{
//originalHeight = transform.position.y; // in case this changes
transform.position.y = Mathf.Lerp(transform.position.y,minimumAllowableHeight);
}
else if (transform.position.y < originalHeight)
transform.position.y = Mathf.Lerp(transform.position.y,originalHeight);
}