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
-1
Question by Max Designer · Jan 08, 2013 at 04:06 PM · javascriptmonodevelop

how do i make when i click on a candle it out and when i click back on it, it's light?

i want to make a candle light and out when i click out it using scripts(Java), for a menu i am trying to make, how do i do this?

Comment
Add comment · Show 3
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 AlucardJay · Jan 08, 2013 at 04:17 PM 0
Share

Information on Light :

http://docs.unity3d.com/Documentation/ScriptReference/Light.html

http://docs.unity3d.com/Documentation/ScriptReference/Behaviour-enabled.html?from=Light

http://docs.unity3d.com/Documentation/Components/class-Light.html

Information on Raycast :

http://docs.unity3d.com/Documentation/ScriptReference/Physics.Raycast.html

Video Links :

http://www.unity3dstudent.com/2010/07/essentials-e08-lights/

http://www.unity3dstudent.com/2010/08/intermediate-i01-raycasting/


Here are some links I strongly suggest to all new users :

Start at the bottom and work up : http://www.unity3dstudent.com/category/modules/essential-skills/

Start at the bottom and work up : http://www.unity3dstudent.com/category/modules/beginner/

this is the YouTube link for the above as one playlist : http://www.youtube.com/watch?v=-oXYHNSmTxg&list=PL27B696FB515608D2&feature=plcp

avatar image Max Designer · Jan 08, 2013 at 05:21 PM 0
Share

thanks alot, i will check it out.

avatar image AlucardJay · Jan 08, 2013 at 05:33 PM 1
Share

I recommend learning raycast, personal experience found On$$anonymous$$ouse functions unreliable, and you can get alot of information from a RaycastHit. When you have built your candle prefab, enable/disable it with SetActiveRecursively for unity 3.x, for Unity 4 use SetActive

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by smirlianos · Jan 08, 2013 at 04:28 PM

Try using this script, that sets the light intensity. It's inside the OnMouseUp function, so the code runs when the user clicks the candle (like the Main Menu). Then if the variable isOnLight is true, it sets the intensity of the light to zero, and if it's not true, it sets the intensity back to 1. Be sure to put a collider in the candle!

(note: I wrote ths script now, so mabey there are some mistakes)

 private var isOnLight : boolean;
 
 function OnMouseUp() {
   if(isOnLight)
   {
       light.intensity = 0.0;
       yield;
       isOnLight = false;
   }
   else if(!isOnLight)
   {
       light.intensity = 1.0;
       yield;
       isOnLight = true;
   }
 }
Comment
Add comment · Show 9 · 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 Max Designer · Jan 08, 2013 at 05:21 PM 0
Share

i guess it won't work because i can a candle, light, and two particle system to make a fire on the candle so it won't work but thanks aways.

avatar image smirlianos · Jan 08, 2013 at 07:34 PM 0
Share

if there is not only the light but all this, try this, that makes the candle(or any part of this, disapear)

 private var isOnLight : boolean;
 var obj1 : GameObject;
 var obj2 : GameObject;
 var obj3 : GameObject;

 function On$$anonymous$$ouseUp() {
   if(isOnLight)
   {
       light.intensity = 0.0;
       yield;
       isOnLight = false;
       obj1.active = false;
       obj2.active = false;
       obj3.active = false;
   }
   else if(!isOnLight)
   {
       light.intensity = 1.0;
       yield;
       isOnLight = true;
       obj1.active = true;
       obj2.active = true;
       obj3.active = true;
   }
 }
avatar image Max Designer · Jan 09, 2013 at 03:29 AM 0
Share

it doesn't work, it's fine

avatar image smirlianos · Jan 09, 2013 at 11:55 AM 0
Share

Why? what problem shows in the console?

avatar image Max Designer · Jan 09, 2013 at 04:33 PM 0
Share

there is no "Light" attach to the game object.

Show more comments

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

10 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

Related Questions

Trivial question for Javascript/Unityscript experts: static variables? 4 Answers

How can i make a main menu? 1 Answer

MonoDevelop Task List with Javascript (TODO, FIXME) 0 Answers

Object deformation on activat 0 Answers

Unity 5.3 MonoDevelop autocomplete Not Working 8 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