How do I get the camera to follow my character?

I’m completely new to Unity! For Javascript specifically, how can I make the Camera follow my character? My friend and I are making a simple 2D platformer.
…and where in the script would it go exactly?

Sorry for the super n00b question,

Thank you!

You should really, really look into some tutorials on Unity. There’s some great ones for 2D stuff.

The easiest way is to simply set the camera as a child object of the player in the inspector. It’ss follow the player just fine.

If you don’t want the camera to move up and down along with the player, you’ll want to script that in. Make a script that checks changes in the player’s x-position, and applies the same change to the camera. I’ll not post any code - you won’t ever learn anything if all you do is copy-pasting answers off the internet.

in the assets pack of unity there is a script known as smooth follow, if you have just started unity that is probably the best option for you.

Please Note → why dont you try importing unity character pack in your scene and have a look at the camera of the Third Person Controller there…

Oh i see you are looking for 2d game, then you have to just disable the Z axis.