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 Bentoon · Mar 07, 2014 at 03:34 AM · positioningscrollingvisible

Turning on Visibility for Camera

Hello People

I have a FPC that have contained to the X-axis for a scrolling game

I need to turn on the mesh renders when the camera hits a certain x pos

and off when the camera moves on (or better yet when Camera is in between certain values )

Any ideas how I would do this?

Thank you !

~Be

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
0
Best Answer

Answer by Bentoon · Mar 08, 2014 at 05:38 AM

Hey Guys, because of how much text needs to be turned on and off, I went with a simple idea:

Making GameObjects that I can duplicate adnauseum each has a plane with collision detection that turns the text elements on and off

Like So:

 var myText: Transform;
 
 
 function OnTriggerEnter (other : Collider) {
 
 Debug.Log("planeHit");
 
 myText.renderer.enabled = true;
 
 }

Thanks for your help SirCrazy Any ideas on streamlining are welcome

~be

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
avatar image
0

Answer by SirCrazyNugget · Mar 07, 2014 at 03:52 AM

Apply a layer to the objects which are to be hidden.

On the camera turn off that layer in the culling mask.

 if(Camera.main.transform.position.x > 0){
   //hide the layer
   Camera.main.cullingMask &= ~(1 << LayerMask.NameToLayer("TheNameOfTheLayerToToggle"));
 }else{
   //show the layer
   Camera.main.cullingMask |= (1 << LayerMask.NameToLayer("TheNameOfTheLayerToToggle"));
 }

Obviously set up a trigger and have it just change when necessary though, this is only a simple example

 //and if you'd prefer to toggle the layer
 Camera.main.cullingMask ^= (1 << LayerMask.NameToLayer("TheNameOfTheLayerToToggle"));

Also, store the LayerMask instead of using the NameToLayer function each time too.

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 Bentoon · Mar 07, 2014 at 06:21 AM 0
Share

Excellent, Will try now, Sir

avatar image Bentoon · Mar 08, 2014 at 02:40 AM 0
Share

Thanks SirCrazy.

$$anonymous$$y problem is that I have a scrolling game with a lot of layers that will be popping on and off as the camera moves endlessly to the right...

So I will be turning layers on and off all the time in the Camera script (update function?)

$$anonymous$$aybe its better to put GameObjects that hold the elements that need to be turned on and off and set an on enter/ on exit script as the Camera Passes through...

Is such a thing possible?

So the Logic I am trying to put on each Game object would be something like:

 on Collision ?  ( the only thing that will be colliding is the FCP&Camera) {
  Camera.main.culling$$anonymous$$ask |= (1 << Layer$$anonymous$$ask.NameToLayer("TheNameOfTheLayerToToggle"));
 }
 
 onExit? {
 Camera.main.culling$$anonymous$$ask &= ~(1 << Layer$$anonymous$$ask.NameToLayer("TheNameOfTheLayerToToggle"));
 }
 
 

But I am having a tricky time writing the code... Thanks!!!

~be

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

20 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 avatar image avatar image avatar image

Related Questions

How to make parent UI element change size to fit children? 0 Answers

parallax scrolling background 2 Answers

Problem with 2D parallax effect (flickering) 1 Answer

Vertical Parallax Scrolling 1 Answer

How do I add a scrolling input text box in an EditorWindow? (more info added) 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