Hello everyone, I am currently facing a problem and could really use some help.
I have implemented an automatic gun in the Unreal Engine that spawns projectile actors. These projectiles can vary, ranging from simple bullets to homing missiles or projectiles affected by gravity. However, I am experiencing significant performance issues when I have around 500 projectiles spawned from the gun, causing the FPS to drop to around 20.
The projectile actors have a hierarchy consisting of
- Static Mesh Component
->Niagara Trail
→ Radial Force Component
- Projectile Movement Component.
To segregate the issue, I have tried removing the mesh component and clearing the Niagara Trail Component. After disabling the tick on the projectile movement component the performance improves.
After researching on the Unreal Engine forums and Reddit, I have come across a few potential solutions, but none seem to fully address my requirements:
1. Line Trace: This may work for projectiles that don’t consider gravity or homing functionality, but it may not be suitable for my case.
2. Niagara Particles: How to pass data between C++ and Niagara Particles. Also Found Niagara Collision to Apply Gameplay Effect? - #9 by Michael.Galetzka which tells to avoid using Niagara Particles.
3. Bullet Manager: Implementing a manager to handle projectile movement with a single tick could be a viable solution, but it may not work well for projectiles with gravity or homing capabilities.
I have also implemented object pooling, which has helped in reducing time that was spent on actor creation and destruction, but it does not have any effect on the active projectiles in the level.
Given my requirements:
-
I need to handle up to 2000 projectiles.
-
The projectiles can be homing missiles, affected by gravity, or simple bullets, and they all need to hit their targets.
This is part of my upcoming Turret Plugin, and as a plugin, I cannot predict the specific usage scenarios. It may be used in large or small levels. For larger levels, I could potentially reduce the tick rate based on the distance from the player.
If anyone has any suggestions or alternative solutions to address this issue, I would greatly appreciate your help. I have been stuck on this problem for a while and any assistance would be immensely valuable. Thank you!"