1
0
Fork 0

Added entity-spawn and kill

This commit is contained in:
ALoTron 2018-04-21 16:12:04 +02:00
parent 3b7457ef1c
commit 1ef7a24142

View file

@ -2,15 +2,31 @@
using System.Collections.Generic;
using UnityEngine;
public class Entity : MonoBehaviour {
// Use this for initialization
void Start () {
public class Entity {
EntityObjective referringObjective;
GameObject entityPrefab;
GameObject instance;
// Constructor
public Entity(EntityObjective referringObjective, GameObject entityPrefab)
{
this.referringObjective = referringObjective;
this.entityPrefab = entityPrefab;
}
// Update is called once per frame
void Update () {
// spawns the entity
public void Spawn(Transform spawnPoint)
{
instance = GameObject.Instantiate (entityPrefab);
instance.transform = spawnPoint;
}
// kills the entity
public void Kill()
{
GameObject.Destroy (instance);
referringObjective.Remove (this);
instance = null;
}
}