I am trying to write a camera script but it is not working as intended.
void LateUpdate(){
if (Input.GetMouseButtonDown(0)
{
_lastPosition = Input.mousePosition;
}
if (Input.GetMouseButton(0))
{
var delta = _lastPosition - Input.mousePosition;
var deltaxz = new Vector3(delta.x, 0f, delta.y);
transform.Translate(deltaxz * Time.deltaTime, Space.World);
_lastPosition = Input.mousePosition;
}
}
I wrote this code to move the camera but the mouse moves the camera strangely. If I move the mouse too fast, it moves fast. If slow, the camera moves slower than mouse.
I think that ScreenToWorldPoint
can help, but the camera is RTS style, I want to move it like I am moving ground "drag and drop" \