hi …,
how can i start making camera move right when mouse cursor reach the right edge of the unity scene and making camera move left when mouse cursor reach the left edge of the unity scene (the scene size is 600x300) …?
Presumably you’ll want a small buffer area on each side of the screen, which would probably most reasonably be expressed as a percentage of the screen height (for consistency between resolutions). The camera should move left whenever the mouse x coordinate is less than this buffer amount, and should move right when the mouse x coordinate is greater than ‘Screen.width - bufferAmount’ (and similarly with the mouse y coordinate).
The movement vector should probably be accumulated each update so that when the mouse is in a corner region, the camera will move along both the horizontal and vertical axes.
Jesse Anders …, first thanks for reply, i want only camera move horizontal left or right … can you tell me the script base ?
Right, sorry (I see you didn’t mention vertical movement in your original post).
In that case, it would just be the horizontal part of what I described earlier. If you’re not sure how to code it, I’d start by detecting when the mouse position is on the left or right side of the screen, and print a message to the console indicating whether the mouse is on the left, on the right, or in the middle area (to make sure it’s working).
The code might look something like this (C#, untested):
var x = Input.mousePosition.x;
if (x < edgeBuffer) {
Debug.Log("Left");
} else if (x > Screen.width - edgeBuffer) {
Debug.Log("Right");
} else {
Debug.Log("Center");
}