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 Xatoku · Sep 07, 2011 at 01:08 AM · colliderstringbooleanenable

Converting a String to Another Object's Boolean

I'm trying to make a system working so that I can enable/disable "Flags" and colliders will turn on/off depending on whether their flag is currently active. This is so I can block off certain portions of the story until they meet a specific requirement.

The problem I'm having is getting a collider to check if it's flag has been activated/de-activated. I need it to be a string I can type in because I intend on having many flags and colliders which will use this, so I need to be able to type in which flag I need to be checked in the inspector, and have the script take it from there.

The example is: I assign the below script to a collider and I type in which Flag it needs to check in order for it to disable. I enable the triggers so the object can become walk-throughable, but currently, if I press "l" nothing happens at all.

 var FlagNeeded = "";
 
 function Update () {
     if(FlagControl.FlagNeeded == true){
         collider.isTrigger = true;
     }
     
     if(Input.GetKeyUp("l")){
         FlagControl.Flag01 = true;
     }
 }

And this goes on the FlagControl, which handles all of the flags.

 static var Flag01 : boolean = false;
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 Waz · Sep 07, 2011 at 01:22 AM 0
Share

So what is the FlagNeeded here supposed to do? Write it in pseudocode, don't worry that it doesn't work.

avatar image Xatoku · Sep 07, 2011 at 01:40 AM 0
Share

FlagNeeded is the string I manually type in, and what I'm trying to do is get the script to see if a boolean with the same name of "FlagNeeded" is enabled in the FlagControl script and if it is to turn on the collider's trigger.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by DaveA · Sep 07, 2011 at 01:25 AM

I think you want a Hashtable. Use the flag name as the key and the value would be the boolean. Have one such thing (singleton or just one instance of a 'flag manager' type of script.

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 Xatoku · Sep 07, 2011 at 01:35 AM 0
Share

Would you $$anonymous$$d giving an example? I'm completely new to Hashtables.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

How do I change the logged text based on a momentary collision? 1 Answer

Convert type `UnityEngine.Collider' to `string'? 1 Answer

Activate one canvas and deactivating the other. 1 Answer

RayCast Boolean Help 1 Answer

Can static objects be enabled/disabled? 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