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
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#
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.
O$$anonymous$$ 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.
Answer by Fattie · Jan 24, 2016 at 05:44 PM
To get you started .. have a script something like this
NeedTracker:MonoBehaviour
{
public bool userHasGotThisOneAlready
}
(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 this (press Play and try it), keep an eye on the Inspector of the various items, notice how the boolean is being affected.
This 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 :)
Sorry if I sound stupid, but what exactly are booleans? :P
booleans have only two values, "true" and "false"
the type is "bool" .. much like "int" or "float"
google it !
@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).
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 program$$anonymous$$g. read up on it! it's easy to google "tutorials c# bool" or "how do I use bool in c#"
enjoy!
Your answer
Follow this Question
Related Questions
The roll a ball script isn't working 3 Answers
Function Not Appearing In OnClick Editor 11 Answers
I can't figure out why this variable is not updating 0 Answers
"Win32Exception: The System cannot find the file specified" 0 Answers
Instantiate And move the GameObject to the click position from another position. 1 Answer