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 Chaotiche · May 18, 2014 at 09:04 PM · javascriptstring

String Problem in Java Script

Here is my script, hopefully it is easier to read now. The complete line for var sirenGameObjects : GameObject[] = GameObject.FindGameObjectsWithTag(tag

is

var sirenGameObjects : GameObject[] = GameObject.FindGameObjectsWithTag(tag.Siren);

I am getting three errors,

Assets/PlayerSightingLast.js(21,93): BCE0019: 'sirens' is not a member of 'String'.

Assets/PlayerSightingLast.js(19,58): BCE0019: 'mainLight' is not a member of 'String'.

Assets/PlayerSightingLast.js(18,62): BCE0019: 'alarm' is not a member of 'String'.

On line 21,19, and 18. Any advice?

 public var position : Vector3 = new Vector3(1000f, 1000f, 1000f);        
 public var resetPosition : Vector3 = new Vector3(1000f, 1000f, 1000f);  
 public var lightHighIntensity : float = 0.25f;                          
 public var lightLowIntensity : float = 0f;                              
 public var fadeSpeed : float = 7f;                                      
 public var musicFadeSpeed : float = 1f;                                 
 
 
 private var alarm : AlarmsLights;                                     
 private var mainLight : Light;                                          
 private var panicAudio : AudioSource;                                    
 private var sirens : AudioSource[];                                     
 
 function Awake ()
     {        
         alarm = GameObject.FindGameObjectWithTag(tag.alarm)GetComponent(AlarmsLights);
         mainLight = GameObject.FindGameObjectWithTag(tag.mainLight).light;
           panicAudio = transform.Find("secondaryMusic").audio;
           var sirenGameObjects : GameObject[] = GameObject.FindGameObjectsWithTag(tag.Siren);
         sirens = new AudioSource[sirenGameObjects.Length];
          for(var i = 0; i < sirens.Length; i++);
     {
         sirens[i] = sirenGameObjects[i].audio;
     }
 }
 
 
 function Update ()
 {
    
     SwitchAlarms();
     MusicFading();
 }
 
 
 function SwitchAlarms ()
 {
     
     alarm.alarmOn = position != resetPosition;
     
    
     var newIntensity : float;
     
     
     if(position != resetPosition)
         
         newIntensity = lightLowIntensity;
     else
         
         newIntensity = lightHighIntensity;
     
     
     mainLight.intensity = Mathf.Lerp(mainLight.intensity, newIntensity, fadeSpeed * Time.deltaTime);
     
   
     for(var i = 0; i < sirens.Length; i++)
     {
         
         if(position != resetPosition && !sirens[i].isPlaying)
             sirens[i].Play();
         
         else if(position == resetPosition)
             sirens[i].Stop();
     }
 }
 
 
 function 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 · Show 1
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 Chaotiche · May 18, 2014 at 07:55 PM 0
Share

the error it was giving me was this Assets/PlayerSightingLast.js(18,68): UCE0001: ';' expected. Insert a semicolon at the end. On line 18.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by KiraSensei · May 18, 2014 at 09:05 PM

Try :

 alarm = GameObject.FindGameObjectWithTag(tag.alarm).GetComponent(AlarmsLights);
Comment
Add comment · Show 3 · 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 Chaotiche · May 18, 2014 at 09:14 PM 0
Share

That fixed the semicolon problem but now there are 3 new errors. Assets/PlayerSightingLast.js(21,93): BCE0019: 'sirens' is not a member of 'String'. Assets/PlayerSightingLast.js(19,58): BCE0019: 'mainLight' is not a member of 'String'. Assets/PlayerSightingLast.js(18,62): BCE0019: 'alarm' is not a member of 'String'. On line 21,19, and 18. Any advice?

avatar image KiraSensei · May 19, 2014 at 11:34 AM 0
Share

The lines you gave don't correspond with your code, except for :

 for(var i = 0; i < sirens.length; i++)

You don't want ";" at the end of this line. And no capital L for length.

Since the errors you have are very basic errors, I think you should learn some basic coding stuff before trying to actually develop your game.

avatar image Chaotiche · May 19, 2014 at 03:54 PM 0
Share

Thank you for bearing with me. I'll go do more tutorial and read more on java scripts before I continue.

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

21 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

Related Questions

Access a GameObject through it's tag, using a string. 1 Answer

Creating multidimensional string array 1 Answer

Problem with looping concatenation with custom class 1 Answer

how do you make a javascript built in string array 0 Answers

Converting a .CSV string array to a float array 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