Camera Movement with Mouse – Unity3D (C#) This type of camera controller is mostly used in RTS projects. You can move camera with mouse movement. There are two types of camera movement with mouse: Touch the edges of screen or drag the mouse. In “Drag the Mouse” movement type, player […]
drag
Drag Object with Mouse – Unity3D (C#) It’s too easy and quick to drag an object with mouse. Just use OnMouseDown() and OnMouseDrag() functions. private Vector3 screenPoint; private Vector3 offset; void OnMouseDown(){ screenPoint = Camera.main.WorldToScreenPoint(gameObject.transform.position); offset = gameObject.transform.position - Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, screenPoint.z)); } void OnMouseDrag(){ Vector3 cursorPoint = new […]
