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 /
avatar image
0
Question by Bella_Cruz · Jun 03, 2011 at 06:35 AM · camerazoom

Problems with second Camera zoom and display

I've already added a GUIText,zoom, zoom text, window script for the display into the GameObject. I played the scene everything worked fine except that the window does not show the display of the 1b/1b2 camera. I think it has something to do with the zoom script below: Any solutions? Please Help!

 var cam1a : Camera;
 var cam1a2 : Camera;
 var cam1b : Camera;
 var cam1b2 : Camera;
 private var baseFOV : float;
 
 function Start () {
     baseFOV = cam1a2.fieldOfView;
     baseFOV = cam1b2.fieldOfView;
     
 }
 
 function Update ()
 {
     if (cam1a.enabled == true)
     {
         
         if (Input.GetKey("1"))
             cam1a2.fieldOfView = baseFOV;
         
         if (Input.GetKey("2"))
             cam1a2.fieldOfView = 30;
         
         if (Input.GetKey("3"))
             cam1a2.fieldOfView = 15;
         
         if (Input.GetKey("4"))
             cam1a2.fieldOfView = 7;
     }
 
 
 
 
     if (cam1b.enabled == true)
     {
         
         if (Input.GetKey("1"))
             cam1b2.fieldOfView = baseFOV;
         
         if (Input.GetKey("2"))
             cam1b2.fieldOfView = 30;
         
         if (Input.GetKey("3"))
             cam1b2.fieldOfView = 15;
         
         if (Input.GetKey("4"))
             cam1b2.fieldOfView = 7;
     }
 
 }
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 Scribe · Jun 03, 2011 at 09:03 AM

Hi there, just formatted your script to be more easily readable. (to do this in future highlight all your code and press the 101010 button, thanks)

firstly on function Start () you change baseFOV to cam1a2.fieldOfView and then change it immediately to cam1b2.fieldOfView so baseFOV = cam1b2.fieldOfView. if you want to save both fields of view then you should have 2 variables baseFOV1 and baseFOV2.

A major problem I can see is you have forgotten to surround every if statement with {} so you write:

 function Update ()
 {
     if (cam1a.enabled == true)
     {
 
         if (Input.GetKey("1")){
             cam1a2.fieldOfView = baseFOV;
     }
 
         if (Input.GetKey("2")){
             cam1a2.fieldOfView = 30;
     }
 
         if (Input.GetKey("3")){
             cam1a2.fieldOfView = 15;
     }
 
         if (Input.GetKey("4")){
             cam1a2.fieldOfView = 7;
     }
     }


also at the moment you have 4 different cameras and from my understanding I thought you would only need 2 however I might be mistaken if your scene is not as I imagined.

I'm guessing you change which camera is enabled in a different script and the problem might be there instead.

you might want to add some debuging or print functions to check if things are getting to places and a t what point your code stops working: after if (cam1b.enabled == true) {

if (Input.GetKey("4")){ cam1b2.fieldOfView = 7; print("cam1b is enabled and 7 pressed")

hope that helps,

Scribe

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 Bella_Cruz · Jun 05, 2011 at 11:00 AM 0
Share

Alright, Thank you thank you

avatar image Scribe · Jun 05, 2011 at 02:35 PM 0
Share

If you managed to get your script to work as a result of my help, I would be grateful if you could accept my answer by clicking the check mark next to the answer. 1) this adds to my karma 2)other users of the site can more easily find the correct answer. thanks

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Camera zooming in and out 1 Answer

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

I am writing a camera script, but it seems not to be working. Any suggestions? 1 Answer

Increase camera Zoom 1 Answer

Use lookAt and transform.translate at the same time 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