Quantcast
Channel: Questions in topic: "parenting"
Viewing all articles
Browse latest Browse all 302

How to Dynamicaly assemble an Object in your Resource Folder

$
0
0
Am trying to dynamically create a platform but I want the tiles to randomly assemble depending on length and type of tile/object I want to be part of the platform. Example = stands for a piece of the platform + equals object ==== ==+== ====== I have a Parent object in my resource folder which contains all I need to make my platform work But I need to dynamically make Sprites / Objects to be children of this parent before I instantiate the entire object. Any Ideas I been looking and trying different things but no success yet. I already tried just to see but just instantiates the parent without the child :( public class testing : MonoBehaviour { public GameObject parent; public GameObject child; void Start () { Vector3 spawnPos = new Vector3(transform.position.x, transform.position.y, 0f); //child = (GameObject)Instantiate(child, spawnPos, Quaternion.identity); // parent = (GameObject)Instantiate(parent, spawnPos, Quaternion.identity); child.transform.parent = parent.transform Instantiate(parent, spawnPos, Quaternion.identity); }

Viewing all articles
Browse latest Browse all 302

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>