Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Solerra · Oct 23, 2014 at 11:47 AM · camera2djavascript

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!

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Solerra · Oct 23, 2014 at 12:37 PM 0
Share

Thanks! I ended up setting the camera as a child. That's exactly what I needed (:

avatar image Baste · Oct 23, 2014 at 03:24 PM 0
Share

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.

2 Replies

· Add your reply
  • Sort: 
avatar image
1

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.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Dimling · Oct 23, 2014 at 11:53 AM 0
Share

And to follow up this answer i think the Unity3d official tutorial is a very good resource for 2D developing:

Link to youtube tutorial

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!

TornardoTwins youtube tutorial part 1

avatar image
0

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.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Making the players head face toward the location of the mouse? 1 Answer

Camera movement in a 2D? (like angry birds) 1 Answer

2d camera help! 0 Answers

How do you switch between cameras? 1 Answer

Looking for picture in picture effect using Canvas Elements and Cinemachine follow target 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges