Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by Mumford-and-Dragons · May 03, 2016 at 05:02 PM · switch cameras

How to camera switch...look through cam1 for 10 seconds, then switches to cam 2

Need help with camera switching. Basically, there is a camera in the corner of the room where the player can look around, for 10 seconds, then it switches to a camera on the bed. All I see online is camera switch with code and pressing buttons, but I dont need that. My teacher mentioned something about turning a camera off and the other one on...but I dont see him till tommorow and want to finish it tonight. Really need help due to my deadline being this Friday!

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

2 Replies

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by Cherno · May 03, 2016 at 05:47 PM

Use a Coroutine.

 public Camera cam_1;
 public Camera cam_2;
 public float waitTime = 10f;
 
 void Start() {
      cam_2.enabled = false;
      StartCoroutine(SwitchCamera());
 }
 
 private IEnumerator SwitchCamera() {
      yield return new WaitForSeconds(waitTime );
      cam_1.enabled = false;
      cam_2.enabled = true;
 }
Comment
Add comment · Show 3 · 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 Flaring-Afro · May 03, 2016 at 05:59 PM 1
Share

Shouldn't line 13 come before 12? Otherwise wouldn't it be possible for a user to see a quick flash of the gray no camera screen (or a lower priority cam)?

avatar image Cherno Flaring-Afro · May 03, 2016 at 06:05 PM 1
Share

That's a good question but the answer is no, it shouldn't / doesn't have to. It all happens within one frame, and only when that frame is finished will any changes become apparent to the user. The camera doesn't render a frame between lines 12 and 13, or between any other lines of code. It all happens after all lines of code have been computed. Only then is the image updated (rendered again), and then it all starts over again for the next frame.

avatar image Flaring-Afro Cherno · May 03, 2016 at 06:12 PM 0
Share

That makes sense, thanks

avatar image
0

Answer by Mumford-and-Dragons · May 03, 2016 at 06:26 PM

Hey @Cherno, thanks for the code. I am out for a little while, but will be home to test it out. Silly question but will it be as easy as just creating a script and adding the code..voila it works? Or will other steps need to be completed in order for it to work? Specific names at specific parts of the code? e.g 'waitTime ', will it be 'waitTime 10seconds);'?

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

I am creating a platform 2d game, this game has two main characters (playable), I want to switch the character during the game. 2 Answers

1st to 3rd person crosshair? 1 Answer

Change Cameras on Collision (Javascript) 0 Answers

camera switch script works? 1 Answer

Is there a way to change between orthographic view and first-person? 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