Download

Projectiles slow

I am playing around a bit with spawning a lot of arrows and unfortunately I get very low fps… This is what it looks like:

2078c1f63d14cabcdcb7d626c6fc0a632de795bd.jpeg

This is the Arrow Spawner blueprint:

I know it’s quiet bad to spawn 50 new arrows every tick and destroy the old ones after 3 seconds, but I have no yet found a way to use a pool of arrows because I would need to reset the projectile which does not seem to be possible.

You see there are always around 50 arrows alive. The tick time of the arrows is 7ms while the tick time of the spawner is 10ms, which is both too much but this should be fine. The problem is the general Tick time of 80ms, the MoveComponentsTime of 62ms and the UpdateOverlapsTime of 43ms.

Are projectiles just generally too heavy for stuff like arrows which are flying “slowly”? I would like to use hundreds of them in game game simultaneously.

This are the settings of the Projectile (the Arrow):

4f8f47d569729e29a8c94380e6e4ae286a64e8db.png

I noticed it runs a lot better in a standalone game. 130ms in Editor (No logging) and 60ms in the standalone game, both with 400 arrows in the air.

I changed my setup a bit, now I spawn the arrows with a velocity of 20000 to make sure they don’t hit anything but always fly before they die 20 seconds after spawn. I want to make sure the spawning itself is not the part which is slowing this down. I now only spawn 20 arrows a second.

I noticed I get quiet some memory allocator calls (whatever this is)

20001aa2ec.png

I also have disabled visibility for the arrows mesh and added an arrow (the debugging arrow) instead, this make it a bit easier on the GPU, but GPU does not matter.

I did a bit of profiling:

Can I do anything to reduce the time the ProjectileMovementComponent needs?

I had this problem in a previous game , what i did is reducing collision Responses and using substeeping

I would hate to be the cavalry if this was an old western and the Indians were attacking. (no offense to our native ‘true owners’ of America btw)

couple suggestions to start with:

  1. if any way possible remove that tick, use an event to fire arrows if ya can, even if it’s a timer
  2. remove that ‘for’ loop. doesn’t look like it’s doing anything but slowing down the tick node. execution will hang for 3 loops doing nothing
  3. this is just a suggestion uncheck that ‘spawn even if colliding’ checkbox in spawn actor node if you don’t really care if they collide when they spawn
    edit: let me add 4) how are you moving them? move component time is really high too. it is possible to remove tick from this too & just use a timer to update every .2 or .3 seconds. just looks really high
    (and reduce arrow model tris &/or simplify the collision you are using with them also might be helpful)

(growing wary of even posting anymore on forums. most don’t understand they never include enough info and seems everyone is so hostile now.)
(but you gave a pretty good idea of what you were trying and what your objectives were, so hope this helps)

I will try reducing collision responses, thanks. But isn’t substepping actually increasing the CPU load?

I use timers for everything

The for loop spawned 3 arrows per one tick, why do you think it did nothing? And I have already removed it.

How am I moving what? I am not sure whether you noticed that I use projectiles? How could I decrease the projectile update frequency? The arrow model tris are actually really low since I only use a cylinder and a cone, but at the moment I disabled visibility for all of these and use an debug arrow. The collision is already extremely simplified, it’s just a small box collision.

Thanks :slight_smile: