Hi All,
I making a small app to find the length of the small objects and radius.
I just want to move my vernier calipers mover object. How will i write script for the moving of the object.
can i get any code or any idea to do that, then i will implement.
using UnityEngine;
using System.Collections;
public class XDrag : MonoBehaviour {
public float sensitivity = 0.02f;
private Vector3 v3Prev;
void Update () {
if (Input.GetMouseButtonDown(0)) {
v3Prev.x = Input.mousePosition.x;
}
if (Input.GetMouseButton (0)) {
transform.position.x += (Input.mousePosition.x - v3Prev.x) * sensitivity;
v3Prev.x = Input.mousePosition.x;
}
}
}
After writing my script i am getting an error like this:
Assets/Scripts/XDrag.cs(14,15): error CS1612: Cannot modify a value type return value of `UnityEngine.Transform.position’. Consider storing the value in a temporary variable
Can i get any help.
Thanks
Shankar