-3

I have a problem . The game scenes lags . When I use this script for spawning the frames on low. It's not running 60fps . Another thing the enemy ai's stop spawning in the scene. I need help here is my code :

    public class EnemiesSpawner : MonoBehaviour { 
        public GameObject enemy; public Transform [] spawnPoints; 
        public float spawnTime = 5f; 
        public Vector3 spawnValues; 
        void Start () { 
            InvokeRepeating("Spawn", spawnTime, spawnTime); //Calls the "Spawn" function every 10 seconds. 
        } 
        void Spawn () { 
            int spawnPointIndex = Random.Range (0, spawnPoints.Length); 
            for( int spawnCount = spawnPoints.Length - 1 ; spawnCount >= 0 ; --spawnCount ) 
                 Instantiate(enemy, spawnPoints[spawnPointIndex].position, spawnPoints[spawnPointIndex].rotation); 
Vector3 s
  • 1
    Please [edit] your question and apply formatting to your code. It's impossible to read like that – Camilo Terevinto May 06 '18 at 01:07
  • You will have to elaborate in more detail what exactly you are expecting. Expecting your game to run at 60fps as beginner is probably unrealistic. What are you using as your inputs? A prefab? – Tyler S. Loeper May 07 '18 at 20:28

1 Answers1

-1

not code but make it have a rigbody and drag the enemy to the side disable everthing on it than addforce to the enemy just enough for it to be in the spot you want it to be for example rb.addforc(0,0,300); see it would add force forward just enough for the camera to see this would prevent lag and make your game better <3.