Hi, I am new to this forum and i am new into unity3D also. I have a simple task wherein i need to instantiate gameobjects when i press "W" key and destroy the same gameObjects when i press "f" key. Till here everything is working fine. But after i destroy the gameobjects , if i press again "F" key the gameobjects doesn appear again. I don wan to use prefab. Could Anyone Help me please please.,.,., Urgent`enter code here
`using UnityEngine; using System.Collections;
public class keyboard : MonoBehaviour { public GameObject newObject; public GameObject new1;
void Update()
{
if (Input.GetKeyDown(KeyCode.F))
{
int i;
for( i=0;i<4;i++)
GameObject.Instantiate (newObject, new Vector3(i * 5.0F, 9, 3), Quaternion.identity);
}
else
{
if (Input.GetKeyDown(KeyCode.W))
{
Destroy(this.gameObject);
newSphere();
}
}
}
void newSphere()
{
int x;
for(x=0;x<4;x++)
GameObject.Instantiate(new1,new Vector3(x * 5.0F, 9, 3), Quaternion.identity);
}
}
Thanks for the reply.,.,!!! i am new to this unity3D.,.,!! can you please tell me how to save the instantiated objects?? using array??? Using array i tried but didn work ,.,., can you please tell me.,., waiting for your reply.,.,
ā Sudarshh123Edited my answer to include some code clips
ā DaveA