Basically whenever I press start the game freezes and I know the trigger sort of. I know it is in one of these 4 scripts because I deactivated the thing that triggers them and there is no freeze. These four scripts spawn in the characters. The first one spawns in the player. The second one spawns in the runner zombie. The third one spawns in the normal zombie and the fourth one spawns in the behemoth zombie. I looked through the code and haven’t found anything but that is because I am a mega noob at coding.
Player Spawner
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RandomSpawn_Player : MonoBehaviour
{
public GameObject Player;
public float xPos;
public float zPos;
// Start is called before the first frame update
void Start()
{
int x = Random.Range(1, 3);
if (x == 1)
{
xPos = 0.5f;
zPos = Random.Range(1, 215);
}
else
{
xPos = Random.Range(1, 165);
zPos = 0.5f;
}
Instantiate(Player, new Vector3(xPos, 0.3f, zPos), Quaternion.identity);
}
}
Runner Spawner
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RunnerRandSpawn : MonoBehaviour
{
public GameObject ZK;
public int xPos;
public int zPos;
public int enemyCount;
// Start is called before the first frame update
void Start()
{
while (enemyCount < 25)
{
xPos = Random.Range(1, 165);
zPos = Random.Range(1, 215);
Instantiate(ZK, new Vector3(xPos, 0.3f, zPos), Quaternion.identity);
enemyCount = enemyCount + 1;
}
}
}
Regular Zombie Spawner
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ZombieRandomSpawn : MonoBehaviour
{
public GameObject ZK;
public int xPos;
public int zPos;
public int enemyCount;
// Start is called before the first frame update
void Start()
{
while (enemyCount < 90)
{
xPos = Random.Range(1, 165);
zPos = Random.Range(1, 215);
Instantiate(ZK, new Vector3(xPos, 0.3f, zPos), Quaternion.identity);
enemyCount = enemyCount + 1;
}
}
}
Behemoth Zombie spawner
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BehemothRandSpawn : MonoBehaviour
{
public GameObject ZK;
public int xPos;
public int zPos;
public int enemyCount;
// Start is called before the first frame update
void Start()
{
while (enemyCount < 10)
{
xPos = Random.Range(1, 165);
zPos = Random.Range(1, 215);
Instantiate(ZK, new Vector3(xPos, 0.3f, zPos), Quaternion.identity);
enemyCount = enemyCount + 1;
}
}
}