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 ina · Nov 27, 2011 at 05:25 AM · cameragameobjectparentchild

Multiple cameras as child or assign coords/rot to main cam

There are several different "states" in my game, each distinct and focused on a different setup. Should I use just a single camera and change coords/rot, or should I assign the entire state to its own gameobject, including all the elements in that state, and the camera as well?

Comment
Add comment · Show 3
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 syclamoth · Nov 27, 2011 at 05:31 AM 0
Share

I don't quite follow. Do the states influence the camera control methods? Are we talking completely different control schemes etc here? I don't think the solution here should be completely one or the other- you should find some middle-ground that has the features you need.

avatar image ina · Nov 27, 2011 at 10:29 AM 0
Share

The states influence the camera position and rotation, since the camera position is optimized for each state. Each state is a distinct bunch of mesh objects tied to an empty gameobject

avatar image syclamoth · Nov 27, 2011 at 10:36 AM 0
Share

Just enable/disable the cameras when you switch states. $$anonymous$$uch simpler that way. (I still don't quite understand your terms here, btw)

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Owen-Reynolds · Nov 27, 2011 at 04:28 PM

I prefer to use one script on one camera, and move it based on the state:

 // Common code for reading scrollwheel:
    ...
 if(placingTowers) {
   camSetUp1();
   // spaceBar places towers, etc...
 }
 else camSetUp2();

A hidden benefit is if you are smoothing the camera (esp with lerp) then you can easily add smooths for switching camera modes (instead of snapping back, you quickly pull back.) Otherwise, camera code is rarely that long and it seems easier to keep it in one file.

A drawback is you can't directly find and adjust "fixed camera 3." If your cameras are different styles (Ortho, narrow view / perspective using render texture) you might use two cams to avoid having to change that in code (or if some things can't be changed in code.)

Performance-wise, I can't think of how either set-up would be better.

Comment
Add comment · Show 2 · 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 ina · Nov 27, 2011 at 11:41 PM 0
Share

Hmm, so perhaps one ortho cam and one perspective cam. What about easily adjusting camera position/rotation in the editor, without getting in a mess?

avatar image Owen-Reynolds · Nov 28, 2011 at 04:31 AM 0
Share

If you have fixed cameras that never move, you may as well change between multiple cameras (one cam could use an array of Transforms, and transform=Cam[0]; but what's the point.)

But, for example, I have something with an "overlook" start menu cam, an "ai$$anonymous$$g" cam and a "follow the shot" cam. Even the overlook cam uses code (to position itself based on the size of the level.) I just put the code for all three in one script, using 1 cam total.

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

Make a simple tree 1 Answer

how do I get reference to a parent or a child? 2 Answers

Unity2D button as child of camera not clickable 1 Answer

How to check parent value instead name value(more details in post) 3 Answers

Display Name Above Object 2 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