how to let the camera follow the mouse

currently i am creating an rts game. i have a hard time in making the camera follow the mouse pointer when i move it. Can you please help me?

If your view is classical rts camera (screen scrolling when the mouse pointer reaches the borders of the screen), then you need to use Input.mousePosition it will give you a vector3.

x and y are the coordinates of your pointer, you just need to know that the bottom-left of the screen or window is at (0, 0). The top-right of the screen or window is at (Screen.width, Screen.height).

see Input.mousePostion

else, if for some reason you’re making a rts with the camera always centered on the mouse, you simply need to use Input.GetAxis(“horizontal”) and Input.GetAxis(“vertical”)