- Home /
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!
Thanks! I ended up setting the camera as a child. That's exactly what I needed (:
That's great. Can you mark the answer you liked best as "accepted"? That'll kick the question out of the queue of Unanswered questions.
Answer by Baste · Oct 23, 2014 at 11:49 AM
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.
And to follow up this answer i think the Unity3d official tutorial is a very good resource for 2D developing:
While the tornardoTwins at youtube has some great beginner tutorials for the 3D part. I would actually start with those, because I think they give a great understanding of how unity works!
Answer by Sarthak123 · Oct 23, 2014 at 02:02 PM
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.