Camera bias on mouse positon, possible?

Hey all,

So I have this idea for a camera script. The game is in 3d, it’s top down and the player moves with WASD and rotates their character via rotating the mouse around their character.

Now, what I would like to accomplish is kind of hard to explain. I want the camera to slightly pan in the direction that the mouse is facing.

So, normally the player camera is centered over the player like so:

but lets say I move the mouse to the far right of the player, I want the camera to pan over to that direction like so:

the same would apply to every to every other direction as well.

I’d also like for it to have a smooth transition from being centered to being panned.

I’m sure it’s possible, but I don’t think I’ve actually seen it done in any other game, so I don’t have any examples. And frankly I’m not sure how to go about doing this in C#.

Any help would be appreciated, thanks.

bump

Sounds easy. Not sure specifically though :slight_smile:

Just play around with mouse position I guess and move your camera accordingly, with some min/max bounds set on it so it doesn’t go to far?

Offhand, I’d InverseLerp mousePosition.x with the left and right edges of the screen, and feed the result into Lerping an offset with the desired world units on the x axis. Then the same for mousePosition.y etc.

–Eric