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

Destroy 1 prefab object and changing the color/image

$
0
0
I want to destroy a created prefab (not all the prefab) and change the color or creating a new prefab on it. I figure out how to create a new image by using Instantiate on the destroyed position and/or changing the color by using renderer material color. But I want to know how to destroy 1 prefab/clone object that use Instantiate first before doing the rest. Anyone can give me hint or idea on how to do it? Tried using Destroy(this.gameObject), Destroy(gameObject), Destroy(GameObject.FindWithTag), etc but they destroy all of my life. ![alt text][1] [1]: /storage/temp/36917-untitled.png using UnityEngine; using System.Collections; public class Life : MonoBehaviour { private GameObject gc; private GameControl gcs; public GameObject lifePrefab; // Use this for initialization void Start () { gc = GameObject.Find ("GameControl"); gcs = gc.GetComponent(); } // Update is called once per frame void Update () { // Get the current life from GameControl if(gcs.getLife() == 2){ // Some code here to destroy 1 prefab life // Create new different prefab at the same position Vector3 newLifePos = new Vector3(-1.4f,0.6f,0); Instantiate(lifePrefab, newLifePos, Quaternion.identity); } } }

Viewing all articles
Browse latest Browse all 508

Trending Articles



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