|
Post by dreadlord on Sept 6, 2016 18:19:54 GMT
Ultimate Spawner I bought this Asset to create some cool Wave / Horde Mode Gameplay. Compared to a Invector Asset it is clunky as hell but is works :-) To make this work with another Asset, you have to tell the Spawner that a instantiated Prefab is Destroyed. This is done by: SpawnableManager.informSpawnableDestroyed(gameObject, true); So this should be called when your AI is dead. I tried several but i can't find the right place. I tried the v_AIMotor in the CheckHealth after isDead=true. This works, but it destroys the whole AIcharacter immediately after health is zero. Aktually, i only want to inform the SpawnManager that the AI is Dead, not destroy the whole thing. Another Problem is Instantianting the AI: Whenever a AI is instantiated by the Spawner i get an Error: NullReferenceException: Object reference not set to an instance of an objectInvector.v_AIAnimator.OnAnimatorMove () (at Assets/Invector-3rdPersonController/Scripts/CharacterAI/v_AIAnimator.cs:59This points to the Navmesh agent i think. Anyhow - it works. So i dont know whats the problem here. I tried this with another AI Asset i own (Paragon Tactical AI). Works. But i cant see where's the difference. Any help is VERY appreciated :-) Ultimate Spawner Scripting Reference
|
|
|
Post by pat19645 on Sept 11, 2016 12:48:19 GMT
dreadlord, the second problem, i also had it with my spawner, i fixed it like this:
In your Invector-Enemy, in Animator, change Update Mode to Animate Physics. That worked for me.
Here's the spawner script.
using UnityEngine;
public class EnemySpawner : MonoBehaviour
{
public int MaxEnemies = 5; // Max number of enemies.
private int teller = 0; // Current number of enemies.
public GameObject enemy; // The enemy prefab to be spawned.
public float spawnTime = 3f; // How long between each spawn.
public Transform[] spawnPoints; // An array of the spawn points this enemy can spawn from.
void Start ()
{
// Call the Spawn function after a delay of the spawnTime and then continue to call after the same amount of time.
InvokeRepeating ("Spawn", spawnTime, spawnTime);
}
void Spawn ()
{
// If all enemies are released...
if(teller >= MaxEnemies)
{
// ... exit the function.
return;
}
// Find a random index between zero and one less than the number of spawn points.
int spawnPointIndex = Random.Range (0, spawnPoints.Length);
teller += 1;
// Create an instance of the enemy prefab at the randomly selected spawn point's position and rotation.
Instantiate (enemy, spawnPoints[spawnPointIndex].position, spawnPoints[spawnPointIndex].rotation);
}
}
|
|
|
Post by dreadlord on Sept 11, 2016 14:50:26 GMT
Thank you Pat, thats very helpful
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Nov 25, 2016 3:48:01 GMT
Thx as well 
|
|
|
Post by fludiImages on Jan 30, 2017 16:12:16 GMT
Here is another Spawn Manager.. using UnityEngine; using System.Collections;
public class SpawnManager : MonoBehaviour {
public int NumberofBots, ActiveBots; public bool[] CurrentBots; public GameObject[] SpawnPoints; public GameObject[] AIPrefabs;
// Use this for initialization void Start() { SpawnPoints = GameObject.FindGameObjectsWithTag("SpawnPoints"); CurrentBots = new bool[SpawnPoints.Length]; }
// Update is called once per frame void Update() { if (ActiveBots < NumberofBots) { int i = Random.Range(0, SpawnPoints.Length); if (CurrentBots == false) { CurrentBots = true; GameObject tmpObject = (GameObject)Instantiate(AIPrefabs[Random.Range(0, AIPrefabs.Length)], SpawnPoints.transform.position, SpawnPoints.transform.rotation); tmpObject.name = "BOT_" + i; ActiveBots++; } } } }
|
|