So basically I have an object in front of the camera and I want the player to be able to move it side to side when holding down a mouse button and dragging. Here is what I have so far. The object does not move at all.
public bool is_handling;
public Vector3 mouseReference;
public Vector3 mouseOffset;
public Vector3 stickPos;
private float sensitivity;
public void Start() {
stickPos = Vector3.zero;
sensitivity = 0.4f;
}
public void Update() {
if(Input.GetMouseButton(1)){
is_handling = true;
mouseReference = Input.mousePosition;
print (mouseReference);
} else {
is_handling = false;
}
if(is_handling) {
print(Input.mousePosition);
mouseOffset = (Input.mousePosition - mouseReference);
print (mouseOffset);
stickPos.x = (mouseOffset.x) * sensitivity;
transform.Translate(stickPos);
mouseReference = Input.mousePosition;
}
}
}