public void CheckDraggable () { RaycastHit hit; if(Input.GetMouseButtonDown(0)) { if(Physics.SphereCast(head.Gaze, 0.3f, out hit, Mathf.Infinity) && hit.collider.GetComponent<ObjectDraggable>()) { obj_Draggable = hit.collider.GetComponent<ObjectDraggable>(); obj_Draggable.RequestOwnership(); dist_Draggable = hit.distance; } } }
void Update () { if(photonView.isMine) { if(isDragging()) { if(Input.GetMouseButton(0)) { Vector3 vel = head.Gaze.GetPoint(dist_Draggable) - obj_Draggable.transform.position; obj_Draggable.ChangeVelocity(vel * vel.magnitude); } else if(Input.GetMouseButtonUp(0)) { obj_Draggable = null; } } } else { transform.position = Vector3.Lerp(transform.position, this.correctPlayerPos, Time.deltaTime * 5); transform.rotation = Quaternion.Lerp(transform.rotation, this.correctPlayerRot, Time.deltaTime * 5); } }