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

Dragging multiple blocks to a grid.

$
0
0
Hey guys, I'm making a block puzzle game where a randomly generated set of coloured blocks needs to be dragged into a grid (think Columns). I need to drag all three items together so I was planning to make all of them children of an empty GameObject, but I can't seem to make this work at all. public class SpawnBlock : MonoBehaviour { public GameObject[] blocks; void Start() { Vector3[] spawnPositions = new[] { new Vector3(-5, 0, 0), new Vector3(-4, 0, 0), new Vector3(-3, 0, 0)}; for (int i = 0; i < 3; i++) { Instantiate(blocks[Random.Range(0,6)], spawnPositions[i], Quaternion.identity); } } } I've tried making a GameObject to parent the blocks to but I'm getting errors whatever I try. Any help would be most welcome.

Viewing all articles
Browse latest Browse all 302

Trending Articles



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