- Home /
 
               Question by 
               DuvE · Nov 24, 2016 at 01:33 AM · 
                instantiateperformanceupdatelagframerate  
              
 
              Lagspike when using instantiate in coorutine
Hi, we making a bullet hell multiplayer game and there is some issues. Currently testing performance with extreme amount of bullets in scene. Question is - why there is time gap in bullet pattern on start? In theory there should be no holes in bullet lines.
Quick video - http://recordit.co/54i6pijp8L
Bullet spawner code:
 public GameObject Bullet;
 public float RepeatTime = 0.5F;
 public int Count = 9;
 public float Angle = 90;
 private float _angleBetween;
 private Quaternion _startRotation;
 bool keepSpawning = true;
 void Start()
     {
         _startRotation = Quaternion.identity;
         _startRotation = transform.rotation; // rotation
 
         _angleBetween = (Angle / Count).Round(2);
 
         StartCoroutine(TimerSpawn());
     }
 
     IEnumerator TimerSpawn()
     {
         while (keepSpawning)
         {
             AddBullet();
             yield return new WaitForSeconds(RepeatTime);
         }
     }
 
     void AddBullet()
     {
         _startRotation = transform.rotation;
         var localRotation = _startRotation;
         for (var j = 0; j <= Count; j++)
         {
             Instantiate(Bullet, transform.position, localRotation, GameObject.Find("SpawnPlace").transform);
             Vector3 tmp = localRotation.eulerAngles;
             tmp.y = tmp.y + _angleBetween;
             localRotation.eulerAngles = tmp;
         }
 
     }    
Bullet code:
 public float Frequency = 100.0f;
 
         protected override void Update()
         {
             transform.Rotate(new Vector3(0, Frequency / (Time.time - StartTime + 1), 0) * Time.deltaTime);
             base.Update();
         }
I also posted on forums about my other issue with animator, but i think lagspike on start have some connection with second problem.
Forum post - https://forum.unity3d.com/threads/animator-issue-in-bullet-hell-game.442498/
               Comment
              
 
               
              Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                