• 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 /
  • Help Room /
avatar image
Question by PlasmaYoshi · Jan 24, 2016 at 05:39 PM · scripting problembeginnerroll a ballbegginercollectible-game-objects

How to make certain collectibles have to be unlocked before being able to be picked up?

I'm still a very early beginner, and I'm 13. But I was intrigued by game developing and scripting. I'm trying to make a game for little kids about the ABC's and numbers, where you have to pick 1 before 2 etc. I'm trying to do that over the Roll-A-Ball project, but the scripting is kinda hard. If anyone can, please let me know how to be able to do that. Thanks in advance. :D

Comment
Fattie

People who like this

1 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 · Jan 24, 2016 at 05:40 PM 0
Share

Hey - are you familiar with List yet? What about arrays?

You are certainly using c# right? Do NOT use javascript at this stage - apart from anything else Unity are removing it soon. Work in c#

avatar image PlasmaYoshi Fattie · Jan 24, 2016 at 05:44 PM 0
Share

No, I don't know List nor arrays. I'm using C# for everything. The problem is in the scripting. I have no idea what to do. I've watched some tutorials from Unity and Brackeys and other people, but I don't know what to do with my scripting since no one I've watched did it.

avatar image Fattie PlasmaYoshi · Jan 24, 2016 at 05:45 PM 0
Share

OK I gave you an answer to get you started. Enjoy!

Good work on c#. In time be sure to find some examples of List

 private List<string> items
 items = new List<string>()
 items.Add("joe")

then check out IndexOf, etc.

1 Reply

· Add your reply
  • Sort: 
avatar image

Answer by Fattie · Jan 24, 2016 at 05:44 PM

To get you started .. have a script somet$$anonymous$$ng like t$$anonymous$$s

 NeedTracker:MonoBehaviour
 {
 public bool userHasGotT$$anonymous$$sOneAlready
 }

(I leave it to you as an exercise to get the syntax right.)

Now, put that on all the objects (the "A", "B", "C" etc.)

Arrange so that when the user clicks on one (say "B"), it sets that boolean as true.

As you do t$$anonymous$$s (press Play and try it), keep an eye on the Inspector of the various items, notice how the boolean is being affected.

T$$anonymous$$s will set you off on the right track. Notice that basically when the user clicks on say "C", you in fact have to check those booleans ... in that example you'd have to be sure "A" and "B" were already true. Right?

Knock yourself out :)

Comment

People who like this

0 Show 4 · 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 PlasmaYoshi · Jan 24, 2016 at 05:47 PM 0
Share

Sorry if I sound stupid, but what exactly are booleans? :P

avatar image Fattie PlasmaYoshi · Jan 24, 2016 at 06:40 PM 0
Share

booleans have only two values, "true" and "false"

the type is "bool" .. much like "int" or "float"

google it !

avatar image PlasmaYoshi · Jan 24, 2016 at 05:56 PM 0
Share

@Fattie I'm trying to do it in C#, not Boo. If I'm barely able to understand C# and JavaScript, then how would I be able to understand Boo? (I'm trying my best not to sound cocky, sorry if it looks like it).

avatar image Fattie PlasmaYoshi · Jan 24, 2016 at 06:41 PM 0
Share

do not post comments as "answers", on this site

"Boo" is totally unrelated (that's just a coincidence)

a "boolean" ("bool") is a basic thing in programming. read up on it! it's easy to google "tutorials c# bool" or "how do I use bool in c#"

enjoy!

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

The roll a ball script isn't working 3 Answers

How can I improve this code? 1 Answer

How can i place subjects in different positions? 0 Answers

2D moving Script 1 Answer

Why my text is overwritten on previous one? 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