Quantcast
Channel: Questions in topic: "follow"
Viewing all articles
Browse latest Browse all 536

Cloning a game object.

$
0
0
Hello! I got a 3D game and I have I want to clone a object. Gamenvisk has politely gave me this code: `using System.Collections; using System.Collections.Generic; using UnityEngine; public class clonefor4 : MonoBehaviour { Vector3 offset = new Vector3(2, 0, 2); // Start is called before the first frame update void Start() { StartCoroutine("Spawner"); } IEnumerator Spawner() { while (true) { **GameObject clone = GameObject.CreatePrimitive(PrimitiveType.Cube);** clone.transform.position = transform.position + offset; yield return new WaitForSeconds(5); } } }` This code works perfectly, but I want to clone a separate game object other than a cube. With only changing the bolded part, is there any way to go about this? Thanks!

Viewing all articles
Browse latest Browse all 536

Trending Articles



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