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 stormygee · Jul 05, 2014 at 05:33 PM · triggertogglebox collider

Trying to turn is trigger on based on variable minimum score

Hi I'm new to unity, and just learning, so if I've missed the obvious, my apologies. I have a ball roller game set up with coin collecting, and a target paddle to hit once the minimum score is reached to move to the next level. The problem I'm having is getting the paddle's is trigger to only be true if the minimum score is 0 or less.

I have the variable currentScore in GameMaster.js

 static var currentScore : int = 0;

which is then set to 2 in the script for testing purposes. (I plan to make it settable as a variable in each level once I've got it working properly.)

The script CoinPickup then subtracts the coin score from the minimum, and the GameMaster script updates the UI depending on the value

 function OnGUI () {
     if (minimumScore > 0)
     {GUI.Box (new Rect (Screen.width/2-sizeX/2, offsetY, sizeX, sizeY), "Collect " + minimumScore +" more coins to win");
     }
 else
     {GUI.Box (new Rect (Screen.width/2-sizeX/2, offsetY, sizeX, sizeY), "Hit the target to end level");
 }    

What I'm trying to do in the HitTarget script attached to the paddle, is make its trigger property toggle on or off depending on the minimum score.

What I have so far is:

 function SetTrigger(){
   if (GameMaster.minimumScore > 0){
     //switch is trigger property on target to true
   }
   //switch is trigger property to false
   }
 }
 
 function OnTriggerEnter( info : Collider){
            // then load the next level
         Application.LoadLevel(Application.loadedLevel + 1);
      }

I want to use both a true and false in case I add enemies or traps to take points away at a later date, I want to be able to deactivate the target as well as activate it.

I've been chasing my tail around these boards all day, and I've tried several approaches, but don't seem to be able to pin down that last bit of code. Any help would be greatly appreciated.

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

Audio Toggle Background Music (With Trigger ) 2 Answers

Trigger not working 2D 1 Answer

Problems making an audio JumpScare 2 Answers

Toggle onPointerDown event 2 Answers

Destroy game object when player enters a box collider 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