using UnityEngine;
using System.Collections;
public class Movement : MonoBehaviour{
public static int speed = 5;
Vector3 point;
void Update(){
transform.position = new Vector3(Mathf.Clamp(Time.time, -2.5F, 2.5F), 0, 0);
}
void OnMouseDrag(){
point = Camera.main.ScreenToWorldPoint(Input.mousePosition);
point.y = transform.position.y;
transform.position = point;
}
}
This is my code above.
It works witohut Mathf.Clamp thing but when I add Mathf.Clamp gameobject goes right and up.I want to limit drag and drop area.How can I do?
- I don’t want to use y axis and it must be fixed.I’m working with x and z axis.
Thanks!