2d camera help!

Hi

I'm trying to create a javascript that would make the camera partially follow the mouse, but mainly the player in my 2d sidescroller! (And its movement should also be smoothed) I need help with it! Any advice will help and be appreciated! Thank you in Advance :)

You could probably use Mathf.lerp for this. Just get the mouse x and y, and your characters x and y and lerp somewhere between it.

Some pseudo code:

camX = Mathf.lerp(characterX, mouseX, .3f);
camY = Mathf.lerp(characterY, mouseY, .3f);
Camera.SetPosition(camX, camY);

Something like that should work, you can change the .3f to something else (1.0f would mean your camera would look where your mouse is, and 0.0f would mean looking directly at the character, .5f is right in the middle ;) )

Hope this helps,

-The Oddler

Mathf.Lerp