- Home /
Dungeon crawler problem(getting transform data from an array)
I'm looking to add stairs to a procedurally generated dungeon floor. I only want one set of stairs on each level of the dungeon, in a random position. I've been working on arrays to solve my problem, by replacing one tile in the dungeon with a set of stairs. I'm trying to store the tiles in an array, then later retrieve their transform data for Instantiation purposes. I tried doing something like this:
void stairdig(){
Transform[] stairPosition;
stairPosition=GameObject.FindGameObjectsWithTag("room");
spotForStairs=(Random.Range(0,stairposition.Length+1));
Instantiate(stairs, spotForStairs, spotForStairs);
}
but unity tells me that i can't simply turn a game object into a transform with this code. is there a way for me to get the transform data from these objects so I can instantiate the stairs in their place? thanks in advance!
Answer by fafase · Nov 30, 2013 at 06:19 PM
stairPosition=(Transform[])GameObject.FindGameObjectsWithTag("room");
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Need help with converting an array to a list in C#` 4 Answers
Null reference when accessing GameObject in the Array(C#) 1 Answer
Vector3 resultant array sorting 2 Answers