hello,
I am having a problem respawning an object, every time it respawns it duplicates in the same position and not in the position i want it to. i have tried a few methods to get it to work but they have all failed. what i would like it to do is to respawn a new object whilst keeping the old ones but respawn in a different location.
here is the code
using UnityEngine;
using System.Collections;
public class Button1 : MonoBehaviour {
public Texture btnTexture;
public GameObject myPrefab;
public Texture btnTexture2;
public Texture btnTexture3;
public float posx;
public float posy;
public float posz;
void Update (){
}
void OnGUI() {
if (!btnTexture) {
Debug.LogError("Please assign a texture on the inspector");
return;
}
if (GUI.Button (new Rect (135, 10, 125, 125), btnTexture)) {
Debug.Log ("1");
Instantiate (myPrefab, new Vector3(posx,posy,posz), Quaternion.identity);
}
if (GUI.Button (new Rect (285, 10, 125, 125), btnTexture2)) {
Debug.Log ("2");
}
if (GUI.Button (new Rect (475, 10, 125, 125), btnTexture3)) {
Debug.Log ("3");
}
}
}