As title stated, when there is too many objects in scene (made when a turret object in my scene shoots too many bullets, they do despawn after a duration so its not completely clogging my scene) my enemies stop moving. Running some debug.logs i have discovered that the script and the line is running, but its just not adding any force, as soon as i stop my turret from firing, they start moving again. What is happening?

Note setting the position directly works regardless of number of entities in scene and using any of the update variations (FixedUpdate etc) does not affect result

  • \$\begingroup\$ You should include the code for the actual movement and if you make a bullet hell type game, you don't want to despawn the bullets but manage them with an object pool (which is way more performant since instantiate is an expensive operation) \$\endgroup\$
    – Zibelas
    Commented Jul 5 at 17:48
  • \$\begingroup\$ void MoveTowards() { if(curTarget == null) { curTarget = GameObject.FindGameObjectWithTag("Target").transform; } transform.LookAt(new Vector3(curTarget.position.x, transform.position.y, curTarget.position.z)); rb.AddForce(eDB.ReturnEnemy(ID).eStats.moveSpeed); } \$\endgroup\$ Commented Jul 6 at 0:56
  • \$\begingroup\$ this is all called in LateUpdate, and i probably should pool the bullets as a made the shooting before i learned how to pool, just need to pool 10000 bullets with several child gameobjects for the models and enable/disable each one as needed \$\endgroup\$ Commented Jul 6 at 0:58
  • \$\begingroup\$ Please include the code in your question (for formatting reasons). 10000 seems as well way to big a number, you won't be able to display that many at once even in a bullet hell game. Another huge performance problem is GameObject.FindGameObjectWithTag - if all 10k bullets ask for this each Update (which should be always the same target, the player, right?), you should probably cache it \$\endgroup\$
    – Zibelas
    Commented Jul 6 at 5:54
  • \$\begingroup\$ the player doesn't shoot, the player summons units that shoot, and each unit can go up to bullet hell levels of shooting (like the enemies in bullet hell games) in order to take down hordes of enemies and thats why i need to prepool a huge amount of bullets. I am looking to put a cap on how many units the player can summon to try and lower the amount of bullets i need to preload. But yea i just realized the findgameobject is probably unnecesary and I could probably replace it with a triggerbox for auto targetting. Also the bullets dont run that script, the enemy does, \$\endgroup\$ Commented Jul 6 at 8:15


You must log in to answer this question.

Browse other questions tagged .