- Home /
Script for collectiong keys to escape
In my game, the character (first person) must collect 5 keys from random places on the large map, and when he collects them, escape from a door. Script?
This situation is described in http://unitybook.net/
You should use: Prefab, Instantiate, OnCollisionEnter or OnTriggerEnter
Answer by Itinerant · Oct 09, 2012 at 05:23 PM
I'm not sure you'll get anyone to write you an entire script, but that shouldn't be too hard to do. Have you done any scripting before? If not, go check out this tutorial: Newbie Guide to Unity Javascript.
Here's a thought on how to solve your particular project, too: declare 5 boolean variables, one for each key. Set a collider around the key, so that when you touch it it flips the variable it's associated with. Once all 5 booleans are flipped, the door opens.
Anyways, go run through the tutorial, try your hand at writing that out, and post your results if you run into issues :)
Answer by AndrewsParodys · Feb 07, 2013 at 06:10 PM
Here, I think I got one for you. Email me at carrandrew1@gmail.com
Your answer
![](https://koobas.hobune.stream/wayback/20220613082106im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to make 2 doors with 2 diffrent keys 2 Answers
Script for a door that requires (9 papers) to open 0 Answers
Animate Doors and Button Through Script 1 Answer
Need help with my animation script 2 Answers
Animation clip does not exist? 1 Answer