Question by
barbarangongong · Mar 05, 2017 at 03:37 PM ·
unity 5
i have a problem i want to destroy a instantiate object in another class
Skript to instantiate a object
using UnityEngine; using System.Collections;
public class spawn : MonoBehaviour {
public GameObject objekt;
public GameObject cube;
// Update is called once per frame
void Update () {
if (Input.GetKeyDown("a"))
{
cube = Instantiate (objekt);
objekt.tag = "spawn";
}
}
}
a script to desroy using UnityEngine; using System.Collections;
public class delete : MonoBehaviour {
public spawn obj;
GameObject [] oj;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
//objeKt = GameObject.FindGameObjectsWithTag ("spawn");
if (Input.GetKeyDown ("s")) {
obj = GameObject.FindGameObjectsWithTag ("spawn").GetComponent (spawn);
Destroy (obj.cube);
}
}
} but that no work i need help please
Comment
Your answer
Follow this Question
Related Questions
Building system problem 0 Answers
[HELP] Unity 5.5 Android build crashes at startup 1 Answer
How to hide the two detection station of the htc vive inside the scene ? 0 Answers
How to record 360 video during gameplay in unity? 1 Answer
Baked materials from blender cycles don't appear right in my scene? 0 Answers