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 DimitriUK · Jan 15, 2014 at 05:01 AM · triggersoundtimerlights

Can anyone help me figure this script out? (Light Trigger)

Hello,

So I am currently working on a Science Fictional personal project and I am working on a scene where the player would enter a trigger and then the lights would turn on individually/in pairs of two, so basically a timer.. Let me give you a better example using the demonstration of the 3D model I am working on.

Example: alt text

It is a very tacky fast rushed example, but I hope you know what I'm trying to achieve from this. Now I could spent time and time and most likely not get this done.. I'm looking for someone who is professional in coding.

If you feel you can do this, that would be great.

The script would run like Player enters trigger >>> Both side lights play in pairs of 2 every 0.2 seconds working its way up the tunne, as well as playing sounds from each one.

examplee.jpg (228.6 kB)
Comment
Add comment · Show 2
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 robertbu · Jan 15, 2014 at 05:20 AM 0
Share

Issue #1: You appear to be looking for a professional to code this for you, which is not what this list is about. You may want to look at the collaboration are a of Unity Forums to find someone to partner with. Issue #2: If you are trying to do this with real lights, and that is an awful lot of pixel lights. Unity supports 4 by default. You need 40 for the drawing above.

This is not a hard problem. There are a couple of different ways to approach the problem partly depending on what language you code in.

avatar image DimitriUK · Jan 15, 2014 at 05:28 AM 0
Share

Alright thank you for the advice buddy, but I appreciate that you looked in to this. Please email me alternatively if you come across anyway who is efficient in JS/C*, and want to get involved in a Sci-Fi Horror based game. Email: Dzangana@hotmail.co.uk, find my project at www.DimaZangana.wordpress.com and head to the Unity Game Development page.

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by nesis · Jan 15, 2014 at 05:40 AM

Make a C# script, attach it to a trigger, and add this code just above the } at the bottom of the autogenerated file:

 public Light[] leftlights; //assign all your left lights
 public Light[] rightlights; //assign all your right lights
 private int currentLight = 0;
 
 public float initialDelay = 0.1f;
 public float delayBetweenLights = 0.4f;

 public void Start() {
     //turn off all lights to start with
     for (int i=0; i<leftlights.Length; i++) {
         leftlights[i].enabled = false;
         rightlights[i].enabled = false;
     }
 }
 
 public void OnTriggerEnter(Collider other) {
     //the tricky part: using InvokeRepeating() to do something over and over over time...
     InvokeRepeating("TurnLightsOn",initialDelay,delayBetweenLights);
 }

 public void TurnLightsOn() {
     //assumes leftlights and rightlights have the same number of elements
     if (currentLight>leftlights.Length-1) return; //early out if we've lit all the lights

     //enable the lights we're currently up to in the arrays
     leftlights[currentlight].enabled = true;
     rightlights[currentlight].enabled = true;
     
     //increment currentLight so next time this method gets called, we're accessing the next light in each array
     currentLight++;

     //we've lit all the lights, so stop calling this method
     if (currentLight>leftlights.Length-1) CancelInvoke("TurnLightsOn");
 }
Comment
Add comment · Show 1 · 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 DimitriUK · Jan 15, 2014 at 01:50 PM 0
Share

This looks good buddy, I'll let you know if it works.

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

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Trigger sound when pressing button 2 Answers

Sound stop when entering trigger 3 Answers

Loop Sounds when within trigger 1 Answer

How can I make a "Fastest Lap" scoring system for a racing game? 2 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