• 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 MoPMetallica · Aug 06, 2012 at 10:56 AM · lightstorch

We're having trouble with our torch turning on and off all lights

Me and a mate are making our own game and we've got a torch for the player and lamps spread across the map. We're having trouble when we turn the torch on and off because when we turn the torch on, all the lamps in the map turn off and vice versa. How can we fix this?

Comment
Add comment · Show 7
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 fafase · Aug 06, 2012 at 10:57 AM 1
Share

We need to see codes. Right now we can only say that maybe you are using FindObjectsWithTag and all torches have the same tag. But how would I know...?

avatar image DESTRUKTORR · Aug 06, 2012 at 04:19 PM 0
Share

fafase is right. You need to post the code, or we won't know what you might have done wrong.

avatar image Eric5h5 · Aug 06, 2012 at 06:02 PM 1
Share

It's likely because you're using static variables, so don't do that.

avatar image MoPMetallica · Aug 07, 2012 at 01:37 PM 0
Share

I don't know if this is the right script and I can't get of my friend because he has the script and I wont be able to see him for a while but we're using the toggleLight.

avatar image Seth-Bergman · Aug 07, 2012 at 01:52 PM 0
Share

@Eric5h5 is right (as always)

wherever toggleLight is declared, it probably says something like:

static var toggleLight : boolean;

just remove the "static" keyword

avatar image MoPMetallica · Aug 07, 2012 at 02:00 PM 0
Share

I think this is our current script

using UnityEngine; using System.Collections;

public class toggleLight : $$anonymous$$onoBehaviour {

// Use this for initialization void Start () {

}

// Update is called once per frame void Update () {

} }

I can't see any 'static' there.

avatar image Seth-Bergman · Aug 07, 2012 at 02:07 PM 0
Share

no... I assumed toggleLight was the boolean, but it seems it's the class

there may be a static boolean declared within.. or it may be what @fafase suggests above..

we need to know more of what's inside this class, at least the relevant part that finds/turns off the light

edit your post, and add the relevant code, and we can figure this out

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Screenhog · Aug 07, 2012 at 04:44 PM

Are you using the same material for the torch and the lamps? If so, are you editing the material directly to turn the torch on and off?

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

12 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

Related Questions

Android Lights Are Messed Up 0 Answers

Object on illuminated by ligth component 1 Answer

How many lights can Unity have at any one time? 2 Answers

Manually Recalculating Lights? 0 Answers

What will be the best light baking settings when baking for mobile devices in Unity 5 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