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 FireHawk33 · Apr 13, 2014 at 03:15 AM · light

What is wrong with my C# script?

I am trying to make a fire, where the light starts to appear as my fire does. I tried to write a code for it, but it simply changed the intensity right when I press play instead of as the fire builds like I want it to.

 using UnityEngine;
 using System.Collections;
 
 public class LightScriptoid : MonoBehaviour {
 
     // Use this for initialization
     void Start () {
     
     }
     
     // Update is called once per frame
     void Update() {
         if(gameObject.particleSystem.startDelay == 2.0f){
             
         }
             gameObject.renderer.light.intensity = 1.0f;
         }
     }
 
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 Scrapy_ · Apr 13, 2014 at 05:39 AM

I recently went through the project tutorials, and I think what you want might be there.. http://unity3d.com/learn/tutorials/projects/stealth/alarm-lights

something like this? a lower fadespeed value will cause the light to fade in slower, and high will increase it.

 using UnityEngine;
 using System.Collections;
 
 public class LightScriptoid : MonoBehaviour {

 
     // Use this for initialization
     void Awake ()
     {
         // When the level starts we want the light to be "off".
         light.intensity = 0f;
     }
 
     void Start () {
         
     }
     
     // Update is called once per frame
     void Update () {
         if (gameObject.particleSystem.startDelay == 2){
             float fadeSpeed = 0.5f;
             gameObject.light.intensity = Mathf.Lerp(light.intensity, 1f, fadeSpeed * Time.deltaTime);
         }
     }
 }
Comment
Add comment · Show 5 · 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 FireHawk33 · Apr 13, 2014 at 09:19 PM 0
Share

Lemme, try that. It looks like it will work.

avatar image FireHawk33 · Apr 13, 2014 at 09:28 PM 0
Share

It worked, thanks a lot! I am sort of a noob at unity. Could you explain to me how that worked? I get most of it, but $$anonymous$$athf.Lerp kind of confuses me a bit! Thanks! :D

avatar image Scrapy_ · Apr 13, 2014 at 09:31 PM 0
Share

glad it worked :)

I'm fairly new myself, the guy in the tutorial explains a little, basically it allows you to increase a value kind of like if you were to adjust a slider. so as the time goes by "fadespeed" the number will rise until it reaches what you have set. so like 0.1,0.2,0.3, up until 1.

not sure if I explained that correctly, but that is my understanding.

avatar image getyour411 · Apr 13, 2014 at 09:33 PM 0
Share

FireHawk33, please click the Accept this Answer as correct icon next to the Answer to earn Scrapy and yourself some karma

avatar image FireHawk33 · Apr 13, 2014 at 09:58 PM 0
Share

I did so! :D Thank's scrappy and getyour411. Im glad you guys arent like the other people who think noob's questions should be gotten rid of. I dont know where Id be then >.<

avatar image
0

Answer by mattyman174 · Apr 13, 2014 at 03:17 AM

 if(gameObject.particleSystem.startDelay == 2.0f)
 {
    gameObject.renderer.light.intensity = 1.0f;
 }

I assume this is what you were meaning to do?

In your original code your changing your light intensity outside of the IF statement.

Comment
Add comment · Show 4 · 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 FireHawk33 · Apr 13, 2014 at 05:05 AM 0
Share

Oh, wow. Conventions fail >.< Thanks! :D

avatar image FireHawk33 · Apr 13, 2014 at 05:09 AM 0
Share

Didnt work. I want it so that when the particle system is at full effect, the light starts up

avatar image FireHawk33 · Apr 13, 2014 at 05:09 AM 0
Share

It still is at Intensity 1 right when I press play

avatar image FireHawk33 · Apr 13, 2014 at 09:17 PM 0
Share

I tried that, but it still changes the intensity to 1 right when I press play. I want the light to show up when the fire is at its fullest extent.

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

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

Related Questions

Brake Light Button 1 Answer

Lightmap - Blotchy & Square 1 Answer

[Q] How do I make a light influence only one object? 1 Answer

shader which only is visible when isn't afected by lights 0 Answers

Changing the position of the light in the Animation Preview window 3 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