Hello,
Sorry if this is a stupid question, but I’m a total novice and I’ve been jumping around to try to find the answer to this for a few hours now (learnt a lot in the process (I think) and it’s been entertaining).
The overall problem is that I’m trying to create a randomly generated platform style level that just goes on and on (seems like a nice idea for a first project in Unity and something I can build on).
I’ve created all my prefabs for the different level tiles / models and my idea was to assign the prefabs to an array so I could just use a random number that would point to that element in the array and then Instantiate that model (the array element was assigned to).
For the life of me I can’t get the array to point to prefabs.
Can anyone please give a sleepy artist a couple of pointers where to look or a bit of a code example please?
Thanks Matthew, that sorted it for me.
It took me about an hour to realize that to change the size value for the array, I actually do it from the editor (spent ages trying to do it in code).
So I now have a very basic randomly generated level set up.
Unity is so different to what I’m use to (BASIC from about 24 years ago), but I’m really enjoying it.
Thanks again for your help, it really is appreciated.
somewhat not even slightly related but may be useful, I made a utility script that finds all the objects tagged in a scene and stores them in an array. If you have a mega scene, and arent sure where or how many items are in there tagged you can use this:
//When you've lost track of tagged objects in your scene, put this in, modify the string, and run. Observe in inspector
var MyTag:String="Player";
var stash: GameObject[];
function Start () {
stash=GameObject.FindGameObjectsWithTag(MyTag);
}
@script AddComponentMenu("DW3D/Utilities/TagFinder")
so add to an empty, define the string (currently player) press play and look in the inspector.