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 pihar · Oct 25, 2015 at 12:21 AM · c#cameraerror-messagecamera.mainswitch cameras

Full screen camera missing?

Hello everybody,

I have just started out with Unity and I am absolutely loving it, however, I stumbled on a pretty simple problem (I hope) that I cannot solve on my own. This is the situation:

I am making a first person shooter which will have x number of weapons. Among those, I have a rocket launcher. When the user holds the right mouse button, the Main Camera should switch to the rocket launcher camera.

Whenever I hold the right mouse button, the screen fills with the following message: "missing full screen camera". This is my current code for the camera switching:

 public Camera playerCam;
 public Camera rocketLauncherCam;
 
 private void Start()
 {
     playerCam.enabled = true;
     rocketLauncherCam.enabled = false;
 }
 
 private void Update()
 {
     if (Input.GetKey(KeyCode.Mouse1))
     {
         playerCam.enabled = false;
         rocketLauncherCam.enabled = true;
     }
     else
     {
         playerCam.enabled = true;
         rocketLauncherCam.enabled = false;
     }
 }

I cannot figure out what I did wrong. Enable one camera while disabling the other one, seemed like the way to go.

I hope this problem is easy to fix.

Thanks in advance and I really appreciate the time you take when you write an answer. Since the solution cannot be that hard, I do not ask for a large explanation. Just a quick overview, otherwise it would take too long (and I learn more by analyzing code).

Have a nice day,

Tahar

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

3 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by SkandYxyz · Oct 25, 2015 at 04:54 PM

I guess you didn't asigned:

public Camera playerCam; public Camera rocketLauncherCam;

Maybe use this instead.

public Camera playerCam; public Camera rocketLauncherCam;

private void Start() { playerCam = GameObject.Find("playerCam").GetComponent(); rocketLauncherCam = GameObject.Find("LauncherCam").GetComponent(); playerCam.enabled = true; rocketLauncherCam.enabled = false; }

private void Update() { if (Input.GetKey(KeyCode.Mouse1)) { playerCam.enabled = false; rocketLauncherCam.enabled = true; } else { playerCam.enabled = true; rocketLauncherCam.enabled = false; } } ,I guess Unity doesn't use

public Camera playerCam; public Camera rocketLauncherCam;

because you didn't initialized them right. Use this instead.

public Camera playerCam; public Camera rocketLauncherCam;

private void Start() { GameObject hand; playerCam.enabled = true; rocketLauncherCam.enabled = false; }

private void Update() { if (Input.GetKey(KeyCode.Mouse1)) { playerCam.enabled = false; rocketLauncherCam.enabled = true; } else { playerCam.enabled = true; rocketLauncherCam.enabled = false; } }

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 pihar · Oct 26, 2015 at 02:34 PM 0
Share

Hello SkandYxyz,

Thank your for your code snippet. I do really appreciate it. I am trying to change the tag first, since that would be the fastest solution. In case it did not work, I will try your code.

Thanks a lot for helping!

Tahar

avatar image pihar · Oct 26, 2015 at 02:57 PM 0
Share

I disabled the camera. Silly me! Sorry for wasting your time!

avatar image
1

Answer by DiegoSLTS · Oct 25, 2015 at 01:54 PM

I'm not sure about this, but try switching the tag from your rocket launcher camera to MainCamera. I guess there should always be a camera with the MainCamera tag since some things depend on Camera.main.

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 pihar · Oct 26, 2015 at 02:32 PM 0
Share

Hello DiegoSLTS,

Thank you for your reply. I thought I has already tried this, but I will try it another time. I hope it works. If it works, I will mark your answer as the solution.

Thanks in advance,

Tahar

avatar image pihar · Oct 26, 2015 at 02:57 PM 0
Share

I disabled the camera. Silly me! Sorry for wasting your time!

avatar image
0

Answer by pihar · Oct 26, 2015 at 03:57 PM

Hello everybody,

Thanks a lot for the responses, but I have already found the solution. I was being incredibly silly! I disabled the gun camera... I re-enabled it and there it was! Everything is working as it is supposed to.

Have a nice day!

Tahar

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

Multiple Cars not working 1 Answer

Strange behaviour when switching camera 1 Answer

Switching from a cinematic cycle to the player camera 0 Answers

Distribute terrain in zones 3 Answers

C# Camera.main.GetComponent: Unknown Word SmoothFollow 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