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 Conect11 · Dec 11, 2013 at 04:48 AM · c#cameraculling mask

Using two cameras simultaneously in the same view

Sorry if something similar has been asked. I've done some searching and didn't find anything. I've had an issue for a while where if my player walks right up to a cube, a 3d model, etc and gets too close they'll see right through it. The standard fix has been to adjust my clipping planes down, but that never worked. (to the shock of everyone - myself included - who said that was the entirety of my issue.) Anyhow, a buddy of mine told me about a clever sounding trick that he had heard about, but never implemented, which I just tried with no success, but before giving up on it I thought I'd toss it to the community to see if it might be a viable option. Essentially, what it involves is making a second camera. (In my case I simply copy and pasted the main camera, changed the tag, allowed it only to see items tagged "building" in the culling mask and removed non - essential items, like the audio listener. I then enabled and activated that camera alongside my main camera, and it took over, so that the ONLY thing I saw were buildings. So I simply enabled it via script, and that meant that only the main camera was active. (so buildings didn't appear at all.) I'll be honest, I'm not married to this idea, and I can walk away from it, but just want to see if what has been suggested is possible. Thanks for your time / help, and God bless. :)

 using UnityEngine;
 using System.Collections;
 
 public class MainMenuCameraSwitch : MonoBehaviour {
 
 
          public Camera camera1;
      
     public Camera camera2;
     
     public Camera camera3;
     
      
     bool camera1ActiveBool;
      
      
     void Start () {
      
     camera1.camera.active = true;
      
     camera2.camera.active = false;    
         
     camera3.camera.active = false;
     Time.timeScale = 0;    
      
     camera1ActiveBool = true;
         
     }
      
      
     void Update () {
      
     //use whatever button you want to toggle
     if(Input.GetButtonDown("Action")){
      
     if (camera1ActiveBool == true)
     {
     camera1.camera.active = false;
     camera2.camera.active = true;
     camera3.camera.active = true;            
     Time.timeScale = 1;        
     camera2.enabled = true;
     camera3.enabled = true;            
     camera1.enabled = false;
     Destroy (this);            
      
     //camera1ActiveBool = false;
                 
      
     }
      
     else if (camera1ActiveBool == false)
     {
     camera1.camera.active = true;
     camera2.camera.active = false;
     camera3.camera.active = false;            
      
     camera1ActiveBool = true;
                  
     }
      
     }
     }
     }
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
2

Answer by foxter888 · Dec 11, 2013 at 08:32 AM

you where almost there trying to figure it out the main trick it's not tags it's actually layers, meaning you set the object you don't want to clip to have a certain layer and the second camera need to have it's Depth higher than the other camera, and set the clear flags setting to Depth only. besides making it on the mask part to only see that layer that you don't want it to clip through.

Comment
Add comment · Show 1 · 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 Conect11 · Dec 11, 2013 at 02:46 PM 0
Share

Hey foxter, thanks for that. Definitely helped me to see each layer properly. :)

Unfortunately, my problem still remains. I can still see through buildings, even with my clipping plain set way down. (that's no indication of the effectiveness of your answer, it just means that my theory didn't hold up)

You rock though, for getting me that far!

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

17 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Third Person Camera Help? 0 Answers

move the object where camera look 0 Answers

UNITY 3D: How to make the camera follow the player? Smoothly 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