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 john 2 · Aug 19, 2010 at 07:09 PM · camera2d-platformercamera-scrolling

Camera scrolling?

i am making a 2d platformer mario type game and a need a camera scrolling script. I've been following the 2d platformer tutorial but their camera scrolling script won't work & has errors. Could someone please help me out to make a camera controlling script?please!? thanks for the help!

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by noradninja · Aug 20, 2010 at 02:06 AM

All you need to do to make the camera follow the character in 2D is this:

Take your Main Camera and position it at a 90 degree angle to your character (so youre looking at the side view of your player). With the Main Camera hilighted in the Hierarchy view, look in the Inspector View and make sure Projection is set to Orthographic to get a truly 2D look and feel. This is all you need to do to get this type of view.

Now, to get the camera to scroll along with your character as he/she/it moves, just position the camera the distance you want it from your player (so they are the size you want), and in the Hierarchy View, drag the Main Camera object on top of your player, making the camera a child object to your player. Now, when your player moves, because the camera is a child of the player, your camera will move with it, always keeping the player centered in view and the world will appear to 'scroll' around the player. This is how the camera works in Super Mario Brothers 3 and up, all the Sonic the Hedgehog games, etc. Easy to do, no scripting required :)

Also, when you ask questions, be more specific. What do you mean by the script 'won't work and has errors'? Tell us the exact errors (copy and paste them from the console in Unity). Post the code of the script (including any modifications you may have made). We can't read minds, and not having this info will completely ruin any chance you have in us helping figure out what is going wrong for you.

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

No one has followed this question yet.

Related Questions

Advice on implementing metroidvania camera 1 Answer

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Use lookAt and transform.translate at the same time 1 Answer

FPS Camera moving by my left mouse button 1 Answer

More Effective Camera Switching 1 Answer


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