|
I'm noticing that when I hold down the fire key, my rapid fire machine gun causes the draw calls to go from 12 to 94. Each bullet is an instantiated prefab right now with a Ideally, since I'm cloning a prefab with an identical material, my draw calls should go from 12 to 13 when I hold the fire button. Should I create a global
(comments are locked)
|
|
Every individual object is at least one draw call whether it shares a material or not. (Except on Unity iPhone, with some restrictions, but even that has overhead compared to one real draw call to begin with.) Generally speaking, for a rapid-fire gun, you wouldn't really generate hundreds of individual objects, because that's a lot of resources to devote to something you don't even see in a lot of detail. Instead you do a raycast or similar, and make an effect that simulates lots of bullets, such as (indeed) a particle system. This is nor really true. If your objects share material (and with some more restrictions: http://docs.unity3d.com/Documentation/Manual/DrawCallBatching.html) they should all go in a single draw call. Though the physics on a whole lot of bullets is very heavy, so doing a raycast is still a better idea.
Jan 03 at 12:15 PM
The Oddler
It was true in 2010, when I answered.... Actually it's still true that making lots of separate bullets is not the best idea, even with dynamic batching (which still has overhead, and sometimes doesn't result in any real performance gain anyway).
Jan 03 at 03:30 PM
Eric5h5
It's true it's not a good idea, the raycast is the better idea, though in my experience dynamic batching gives a considerable performance gain (with thousands of objects, running at 60fps and 30 on ios (ios is capped at 30))
Jan 03 at 05:41 PM
The Oddler
iOS isn't capped at 30; you can use Application.targetFrameRate = 60 (which it is capped at, since the screen has a 60Hz refresh rate with vsync forced on).
Jan 03 at 06:21 PM
Eric5h5
Weird, then why does xcode shows maximum of 30fps? (in any project, even when there's nothing)
Jan 03 at 06:29 PM
The Oddler
(comments are locked)
|
