- Home /
HELP with respawn point scripting
Using the default "orb" enemy that unity gives you for the 3d shooter example, i made a respawn point with this:
using UnityEngine; using System.Collections; using System.Collections.Generic;
public class EnemySpawn : MonoBehaviour {
public string pointName;
public Vector3 point;
public GameObject entity_type;
public int defaultLeash;
public List<Object> entity_list;
public float spawnTimer, spawnTimeout, clampX, clampZ;
public int xRange, zRange, spawnCount;
void Start () { point = transform.position; defaultLeash = 20; spawnTimer = 0.0f; spawnTimeout = 5.0f; spawnCount = 5; }
void Update () {
spawnTimer += Time.fixedDeltaTime;
if (spawnTimer > spawnTimeout && entity_list.Count < spawnCount)
{
clampX = Random.Range(point.x - xRange, point.x);
clampZ = Random.Range(point.z - zRange, point.z);
entity_list.Add(Instantiate((Object)entity_type, new Vector3(clampX, point.y, clampZ), new Quaternion()));
spawnTimer = 0.0f;
}
}
}
All the orbs do is hit the ground firing randomly, rather than floating and tracking me like they are supposed to... is this a problem with the respawn point or with the orb script??? HELP!!!
Answer by Parthon · Apr 04, 2011 at 08:23 PM
Definitely with the orb script, there's nothing in the spawn script that affects how the orb behaves.