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 /
This question was closed Dec 01, 2012 at 09:43 PM by Eric5h5 for the following reason:

Duplicate Question

avatar image
0
Question by Konkor4 · Dec 01, 2012 at 09:01 PM · valueget

How to get a value set by another script?

So basically I have a script attached to objects that when they are pressed on it deletes them and adds 1 to a GUItext counter. I'm doing this with

 var PageCount : GUIText;
 var Count : int;
 var Pickup : AudioClip;
 
 function Touched(hit:RaycastHit)
 {
     Destroy(gameObject);
 }
 
 function Update () {
     
 if ( Input.GetMouseButtonDown(0)){
        var hit : RaycastHit;
        var ray : Ray = Camera.main.ScreenPointToRay (Input.mousePosition);
        
     if (Physics.Raycast (ray, hit, 0.8))
       {
          hit.transform.SendMessage("Touched", hit, SendMessageOptions.DontRequireReceiver);
          Count ++;
          PageCount.guiText.text = Count.ToString();
          audio.PlayOneShot(Pickup);
          if(Count >= 3){
           Application.LoadLevel(2); 
           }
       }
    }
     
 }

But I like to keep my scripts tidy so I have scripts for independent things, I want to have another script that controls the enemies rate of spawn to increase a different level each time an item is collected. So for example when the pagecount = 1 I want the enemy to spawn at a rate of 8 but when pagecount = 2 I want him to spawn at say 5. Since my enemy spawn is in an entirely different script how would I go about getting the value of pagecount and using it in an if statement?

Comment
Add comment · Show 3
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 Fattie · Dec 01, 2012 at 09:01 PM 0
Share

this has been explained some 17,000 times on this web site

go to unityGE$$anonymous$$S.com for a $$anonymous$$ASSIVE beginner exposition of the issue

avatar image Konkor4 · Dec 01, 2012 at 09:10 PM 0
Share

Rather keep it on this site, but thanks.

avatar image Eric5h5 · Dec 01, 2012 at 09:44 PM 0
Share

Do a search next time please.

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

11 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

Related Questions

Script for blowing to a particle system 0 Answers

Sending value stored in an array to another script with cSharp 3 Answers

how to get value from other script? 1 Answer

Help on a Power-Up Sequence 1 Answer

issues passing a value form one script to another 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