Quantcast
Channel: Questions in topic: "clone"
Viewing all articles
Browse latest Browse all 508

What can I do to make the objects I instantiated move with the background?

$
0
0
I created an empty object called SpawnManager. I wrote the code for instantiating and moving and added prefabs. But since the instantiated objects are not cloned as children of SpawnManager object, I cannot move them. What can I do to move the instantiated objects? public GameObject[] obstaclePrefab; private float startDelay=2; private float repeatRate=2; public float spawnPosX=5; public float spawnPosY=15; void Start() { InvokeRepeating("SpawnObstacle", startDelay, repeatRate); } void SpawnObstacle() { Vector3 spawnPos=new Vector3(Random.Range(-spawnPosX, spawnPosX),Random.Range(-spawnPosY,spawnPosY),-5); int spawnIndex = Random.Range(0,obstaclePrefab.Length); Instantiate(obstaclePrefab[spawnIndex], spawnPos, obstaclePrefab[spawnIndex].transform.rotation); }

Viewing all articles
Browse latest Browse all 508

Trending Articles



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