#ok i can do that

1 messages · Page 1 of 1 (latest)

idle aspen
#

Then can you paste all your new code once you finish that in here please?

nocturne owl
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Spawner : MonoBehaviour
{
    public GameObject[] spawners;
    public GameObject[] enemy;
    public int dice = 10;
    private int enemyChance;
    private int enemyChoice;
    public int spawnAmount = 10;
    private int spawnerSelector;
    private float delayFinal;
    public float delayMin = 5.0f;
    public float delayMax = 8.0f;
    public Difficulty difficulty;
    public Brain brain;
    public bool spawnDone;
    public int enemiesRemaining;


    // Start is called before the first frame update
    void Start()
    {
        spawnDone = true;
        enemiesRemaining = 0;
    }

    // Update is called once per frame
    void Update()
    {
        spawners = GameObject.FindGameObjectsWithTag("spawner");
        if (enemiesRemaining == 0 && spawnDone == true)
        {
            StartCoroutine(Spawn());
            spawnDone = false;

        }
    }

    public IEnumerator Spawn()
    {
        for (int i = 0; i < spawnAmount; i++)
        {
            //get chance for each enemy wighted by dice. I get enemy chance which is a range from 0/dice and use the outcome to select which monster to spawn.

            enemyChance = Random.Range(0, dice);


            if (enemyChance < 70)
            {
                enemyChoice = 0;
            }

            else if (enemyChance > 70 && enemyChance < 90)
            {
                enemyChoice = 1;
            }

            else if (enemyChance >= 90)
            {
                enemyChoice = 2;
            }

            spawnerSelector = Random.Range(0, spawners.Length);


          Instantiate(enemy[enemyChoice], spawners[spawnerSelector].transform.position, enemy[enemyChoice].transform.rotation);

            delayFinal = Random.Range(delayMin, delayMax);

            yield return new WaitForSeconds(delayFinal);
        }
        spawnDone = true;
        difficulty.IncreaseDifficulty();
    }
}
idle aspen
#

What is delayFinal set to

#

in inspector

#

Oh nvm

nocturne owl
#

it works except for one error

#

well, I want 3 layers of difficulty scaling

idle aspen
#

whats the error

nocturne owl
#

i pick a random enemy from the list of enemies

#

then i pick a random location from a list of spawners

#

then i pick a random delay between a minimum amount of time and a maximum amount of time

#

after all of that i want the wave to end

#

when the wave ends those 3 things are set to be harder next round

#

and when the character enters and then exits the shop the next round will begin

#

the dice variable is so that I can gate the percentage chance of each mob, so in the first few rounds it will only be the basic enemy, then a small percent of the next ememy, and eventually a predetermined chance to spawn all 3

#

this is the error

#

NullReferenceException: Object reference not set to an instance of an object
moveTp.Start () (at Assets/Scripts/moveTp.cs:13)

#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class moveTp : MonoBehaviour
{
    private GameObject goal;
    private GameObject spawner;
    // Start is called before the first frame update
    void Start()
    {
        spawner = GameObject.FindGameObjectWithTag("SpawnManager");
        spawner.GetComponent<Spawner>().enemiesRemaining += 1;
        goal = GameObject.FindGameObjectWithTag("goal");


        UnityEngine.AI.NavMeshAgent agent = GetComponent<UnityEngine.AI.NavMeshAgent>();
        agent.destination = goal.transform.position;
    }

    // Update is called once per frame
    void Update()
    {

    }

}

#

its in this script for the enemy

#

its a temporary script, im just trying to get the backend spawning and pathfinding working so i can start designing the gameplay

idle aspen
#

Do you have a mic?

nocturne owl
#

but it was working before

#

sure

#

i can use my phone

idle aspen
#

Can you screen share your project so i can see it in realtime?

#

or nah

nocturne owl
#

sure