hey gang Made a simple scriptwere when you Kill a Bunch of enemies and when their are no enemies in the group it finds the last Vector3 of the last enemy and then Instantiates and Item,
Just wondering how you use a Vector3 as the posisoin rather then using Transform.posision, ?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SquadrinKill : MonoBehaviour {
public GameObject[] Squadrin;
public GameObject Item;
public Vector3 ItemSpawnpoint;
// Update is called once per frame
void Update () {
// Get Last posision of Lsat Squadrin Member
if (Squadrin.Length == 1) {
ItemSpawnpoint = Squadrin [1].transform.position;
}
if (Squadrin == null) {
GameObject Clone = Instantiate (Item, ItemSpawnpoint);
}
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SquadrinKill : MonoBehaviour {
public List <GameObject> Squadrin;
public GameObject Item;
public Vector3 ItemSpawnpoint;
// Update is called once per frame
void Update () {
for(int i = 0; i < Squadrin.Count; i++){
if(Squadrin *== null){*
Squadrin.RemoveAt(i) i–; }
} if (Squadrin.Count == 1) { Debug.Log (“PRINT pOSISION FOR iTEM” + ItemSpawnpoint); // Not Being Printed ItemSpawnpoint = Squadrin[0].transform.position; }
// Get Last posision of Lsat Squadrin Member if (Squadrin.Count == 0) { GameObject Clone = Instantiate (Item, ItemSpawnpoint, Quaternion.identity); // Not Instaniating Destroy (this); } } }
Instantiate takes 3 arguments if you want to create an object at a position. Also you should destory the object after otherwise it wil keep spawning the object