Question by
niraj005 · Aug 11, 2017 at 06:49 AM ·
dragrigidbody
Why is my mouse onDrag not working
i am making a carrom game and I cannot seem to move my object to which the script is attached by using onDrag mouse .
using UnityEngine; using System.Collections;
public class DragScript : MonoBehaviour {
private Vector3 dragPosition;
private Vector3 leftLimit;
private Vector3 rightLimit;
void Start(){
leftLimit=new Vector3(0,0,-3.02f);
rightLimit=new Vector3(0,0,-3.52f);
}
void onMouseDrag(){
dragPosition = new Vector3 (0, 0, Input.mousePosition.z);
}
// Update is called once per frame
void Update (){
if (transform.position.z > leftLimit.z && transform.position.z < rightLimit.z) {
transform.position = dragPosition;
}
}
}
Comment