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

Trying to Instantiate() an object without cloning the code

$
0
0
I'm trying to make an object that'll duplicate itself in random positions, but when I duplicate it, it also duplicates the code. The clone then starts the code which makes another code, exponentially killing my computer. Is there a way to fix this? public class CloneMe : MonoBehaviour { // Start is called before the first frame update public GameObject self; void Start() { int amountOfClones = Random.Range(10, 15); for (int i = 0; i < 1; i++) { transform.position = new Vector2(Random.Range(0, 7), Random.Range(0, 7)); Instantiate(self); } } } There's no errors showing up from Unity, just insane lag that makes me have to unplug my computer.

Viewing all articles
Browse latest Browse all 508

Trending Articles



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