Hello. I'm new in Unity3D. I'm developing a top-down game (2D Game). I have a floor prefab and I want to instantiate it, but its spawn position in YAxis has to be upper edge of previous floor prefab.
What I want to achieve is: For example, I want to construct a 5 floors building.
Here's my GameSrarter script.
using UnityEngine;
using System.Collections;
public class GameStarter : MonoBehaviour {
void Awake(){
// First prefab is instantiated Vector2.zero position.
GameObject floor1 = Instantiate(Resources.Load("Prefabs/floor"), Vector2.zero, Quaternion.identity) as GameObject;
// But I cannot find upper edge of floor1 prefab as Vector.
GameObject floor2 = Instantiate(Resources.Load("Prefabs/floor"), IDontKnowHowToSpecifyThisOne, Quaternion.identity) as GameObject;
}
}
Thanks for your helps.
↧