Which is more expensive? (Performance-wise)

In terms of performance, which is more expensive:

  1. n un-guided projectiles
  2. 1 un-guided projectile performing n hit traces every tick, where the length of the hit trace is equal to the distance moved between ticks

Are these projectiles actors and wouldn’t each one in your first option still have a single line trace each?

Yes the projectiles would be an actor.
But no the first option would not be given a per tick trace.

The point is whether a number of projectile actors(without traces) would cost more or less than a single projectile actor with a number of traces.

Ah, the good ol’ Memory vs Processing argument.

Let’s break things down.

Option 1 (N number of projectiles)

  • Easy to Debug (no diving into raycast results).
  • More flexible as you could have various types of projectile behaviors/styles and the system would “just work”.


  • Object overhead (Memory cost).
  • Iteration overhead (Draw calls, Update calls).

Option 2 (Uber projectile)

  • Very little object overhead, iteration costs.


  • More difficult to debug (multiple raycast results you need to check through).
  • Raycasts can be very expensive depending on their length.
  • Less flexible in terms of future changes.

You can mitigate some of the overhead from Option 1 by using an Object Pool so you only pay the overhead costs once and then just reuse the same objects over and over (@BrUnO XaVIeR has a Plugin that does just that: Object Pool Plugin in Code Plugins - UE Marketplace ). Option 2 might be fine, depending on your raycast lengths and if you simply can’t spare the memory.

Truth be told, you can guess at an approach all day long but you won’t know how things perform and where your bottlenecks are until the system are in place and you profile things. All things being equal, I would go with Option 1 with an Object pool type system.

1 Like

If we’re talking about a weapon that is firing a lot of bullets that the players don’t really see, like a traditional assault rifle or something, then I would be using ray traces. In fact, I wouldn’t even have an actor at all. I would simple have a class that manages these ray traces for a given weapon.

If we’re talking about a cartoon style weapon that fires oversized rockets for example and there is less of them, then I would probably use actors so you can visualise them, apply effects and use built-in collision.

Like @ExtraLifeMatt said, you won’t really know until you try something out. Best thing to go would be to go for the simplest approach that you can implement and then worry about performance if it turns out to be a bottleneck.