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 bat__banana · Feb 17, 2014 at 12:26 PM · getcomponentfunctioncompilingexecution-order

function execution order

I have a function that I want to call right at the start of my Game Loading.

 function increaseCounter()
 {
 Number++
 }

I'm sure you can see that it adds one point to the counter each time. This function is also used on another game object. However it keeps says "unkown identifier 'increaseCounter' " I read some stuff about the compiling order and placed the script with thr original function into the Standard Assets folder but that didnt work. I've also read about Get.Component, is that appropriate for what i want here?

Any pointers on what i need to be doing would be greatly appreciated :)

Thanks!

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 wibble82 · Feb 17, 2014 at 12:34 PM 0
Share

Hi

The problem might be to do with the script its part of - could you post a little bit more code - the script its defined in, and the script that causing the compile error?

-Chris

avatar image bat__banana · Feb 18, 2014 at 08:07 AM 0
Share

Sorry, I'll explain it better. I have a 'Timer.js' script which has the following code:

          var HoopNumber :  float;
          var timer : float;
          var startTimer = false;
          var destroyTime = 3.0f;
             
          function IncreaseHoops()
           {
             HoopNumber++;
           }

         function OnTriggerEnter ()
           {
              if (gameObject.tag == "startHoop")
              {
             IncreaseHoops();
             startTimer = true;
             yield WaitForSeconds(destroyTime);
             renderer.enabled = false;
              }
           }
             
          function Update
           {
             if(startTimer)
             { 
                timer += Time.detlaTime;
             }
           }

This script is attached to the 'start hoop' with a tag of "startHoop" in the game (the player races around a track, passing through all the hoops to avoid time penalties) This adds 1 to the hoop timer and starts the timer. It also makes the ring not visible to the player so they can see they have passed through it.

I now want another script that is attached to the rest of the 'normal rings' that adds 1 and makes the ring disappear. This is were I really get stuck. The next script is 'ringPickup.js'. At the $$anonymous$$ute i'm not sure whether I need the script attached to all the hoops? Or do i put it on an empty game object and it will it work with any hoops tagged "Pickup"?

The main issue is the following scripts keeps throwing an error saying unkown identifier 'IncreaseHoops'

 var destroyTime = 3.0f;
 
 
 function OnTriggerEnter()
  {
     if (gameObject.tag == "Pickup")
     {
     IncreaseHoops();
     yield WaitForSeconds(destroyTime);
     renderer.enabled.false;
     }
  }

$$anonymous$$y hope was this code would get the IncreaseHoops function from the previous script.

Please excuse any typos (unfortunately I cant copy and paste my code) PS This is my first project so if it a simple mistake, then my apologies!

PPS having some trouble with formatting the code here so sorry if it comes out bad!

Thanks

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Nicolaj Schweitz · Feb 17, 2014 at 12:36 PM

Does this compile? - notice the semicolon:

 function increaseCounter()
 {
 Number++;
 }
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 bat__banana · Feb 17, 2014 at 01:41 PM 0
Share

Damn-sorry that was just a type. It does have a semicolon on the actual script.

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

Accessing a variable within a function.... GetComponent() 2 Answers

get component javascript from a c# script 3 Answers

script with individual function for each gameObject or public script variable to solve inventory system problem 1 Answer

How to call function from another script ? 1 Answer

What is the general use of Awake(), Start(), Update(), FixedUpdate(), LateUpdate()? 7 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