Quantcast
Channel: Latest Questions on Unity Answers
Viewing all articles
Browse latest Browse all 171066

How to instantiate a gameobject by aligning it to another one

$
0
0
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.

Viewing all articles
Browse latest Browse all 171066

Trending Articles