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 mcfetrmatt · May 27, 2012 at 06:23 AM · collisionlightsdirectionalflashing

Light effects on collision

Hi there,

I have attached a flashing script to a directional light and wish to queue the light to enable after a collision later on in the scene. Any ideas as to how to best do this??

Many thanks

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
0

Answer by GC1983 · May 27, 2012 at 06:34 AM

A flashing light? You could just set a timer to turn the object off and on. LightObject.light.enabled = false/true; should be correct. Just set a deltaTime timer on Update().

Comment
Add comment · Show 6 · 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 mcfetrmatt · May 27, 2012 at 08:16 AM 0
Share

Thanks Greg, I now get the error: Assets/Scripts/LightTrigger.js(4,9): BCE0005: $$anonymous$$ identifier: 'LightObject'.

$$anonymous$$y code thus far is:

var flashinglight: GameObject;

function Awake(){

 LightObject.light.enabled = false;

}

function OnTriggerEnter(trigger: Collider){

 LightObject.light.enabled = true;

}

avatar image GC1983 · May 27, 2012 at 08:21 AM 0
Share

flashingLight is your LightObject. flashingLight.light.enabled = true;

avatar image mcfetrmatt · May 27, 2012 at 08:40 AM 0
Share

I'm still getting errors...? I went to this page: http://unity3d.com/support/documentation/ScriptReference/Light.html to get some scripting but not sure if that was the right thing to do?

var flashinglight: GameObject;

var enabled: boolean = false;

function OnTriggerEnter(trigger: Collider){

 flashinglight.light.enabled = true;

}

avatar image GC1983 · May 28, 2012 at 05:07 PM 0
Share

What errors?

avatar image mcfetrmatt · May 29, 2012 at 12:22 AM 0
Share

I am getting this error: $$anonymous$$issingComponentException: There is no 'Light' attached to the "WaterDay(Trigger)" game object, but a script is trying to access it. You probably need to add a Light to the game object "WaterDay(Trigger)". Or your script needs to check if the component is attached before using it. LightTrigger.Update () (at Assets/Scripts/LightTrigger.js:13)

I have attached my directional light to the var created in the inspector panel... So I'm not sure what I'm missing??

Code: var flashinglight: GameObject;

var intensity: float;

var duration: float = 1.0;

var enabled: boolean = false;

function OnTriggerEnter(trigger: Collider){

 flashinglight.light.enabled = true;

}

function Update() {

 var phi : float = Time.time / duration * 2 * $$anonymous$$athf.PI;

 var amplitude : float = $$anonymous$$athf.Cos( phi ) * 0.5 + 0.5;

 light.intensity = amplitude;

}

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Police Flashing Lights? 4 Answers

How to make flashing/blinking/flickering lights? 1 Answer

Police flashing light script 2 Answers

Disabling objects from Collision detection 1 Answer

Done Everyyyy thing but OnCollision is not working!! 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