Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Mr.Sleek · Sep 06, 2015 at 12:46 PM · script.stealthgamecontroller

Stealth Tutorial - gameController

i was learning from one of your tutorials: unity stealth 4x: gameController. I have done everything right and there are no errors on my console, but when i hit play and change the position of x, y or z in the script component in gameController, the alarm doesn't go off. i changed the FindChild to just Find as well. Still no luck. I have unity 4.5 i have pasted a copy of the script that i am using below. Could you please have a look. Thank you in advance.

using UnityEngine; using System.Collections;

public class LastPlayerSighting : MonoBehaviour { public Vector3 position = new Vector3(1000f, 1000f, 1000f); public Vector3 resetPosition = new Vector3(1000f, 1000f, 1000f); public float lightHighIntensity = 0.25f; public float lightLowIntensity = 0f; public float fadeSpeed = 7f; public float musicFadeSpeed = 1f;

 private AlarmLight alarm;
 private Light mainLight;
 private AudioSource panicAudio;
 private AudioSource[] sirens;

 void Awake()
 {
     alarm = GameObject.FindGameObjectWithTag(Tags.alarm).GetComponent<AlarmLight>();
     mainLight = GameObject.FindGameObjectWithTag(Tags.mainLight).light;
     panicAudio = transform.Find ("secondaryMusic").audio;
     GameObject[] sirenGameObjects = GameObject.FindGameObjectsWithTag(Tags.siren);
     sirens = new AudioSource[sirenGameObjects.Length];

     for(int i = 0; i < sirens.Length; i++)
     {
         sirens[i] = sirenGameObjects[i].audio;
     }
 }

 void update()
 {
     SwitchAlarms();
     MusicFading();
 }

 void SwitchAlarms()
 {
     alarm.alarmOn = (position != resetPosition);

     float newIntensity;

     if(position != resetPosition)
     {
         newIntensity = lightLowIntensity;
     }
     else
     {
         newIntensity = lightHighIntensity;
     }

     mainLight.intensity = Mathf.Lerp (mainLight.intensity, newIntensity, fadeSpeed * Time.deltaTime);

     for(int i = 0; i < sirens.Length; i++)
     {
         if(position != resetPosition && !sirens[i].isPlaying)
         {
             sirens[i].Play();
         }
         else if(position == resetPosition)
         {
             sirens[i].Stop();
         }
     }
 }

 void MusicFading()
 {
     if(position != resetPosition)
     {
         audio.volume = Mathf.Lerp(audio.volume, 0f, musicFadeSpeed * Time.deltaTime);
         panicAudio.volume = Mathf.Lerp(panicAudio.volume, 0.8f, musicFadeSpeed * Time.deltaTime);
     }
     else
     {
         audio.volume = Mathf.Lerp(audio.volume, 0.8f, musicFadeSpeed * Time.deltaTime);
         panicAudio.volume = Mathf.Lerp(panicAudio.volume, 0f, musicFadeSpeed * Time.deltaTime);
     }
 }

}

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

0 Replies

· Add your reply
  • Sort: 

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

2 People are following this question.

avatar image avatar image

Related Questions

Does anyone have any experience scripting trees onto a heightmap? 1 Answer

Make Script Component Do Things Even When Game Is Closed 2 Answers

Loading Scripts from asset bundle in iOS and WebGL. 0 Answers

How do i make the player to walk to where the mouse cursor position was clicked ? 0 Answers

What's wrong? 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