Search Unity

Conserving Performance?

Discussion in 'Scripting' started by yair1221, Feb 10, 2012.

  1. yair1221

    yair1221

    Joined:
    Sep 28, 2011
    Posts:
    39
    Hi, I made a missile system, with guidance and everything
    The only problem is the missile trails, it works fine up until 10 missiles.
    But then it all slows down and my computer almost kills itself, reaching 15 FPS barely...

    Now other than that, My scene is almost empty, and I doubt that the 5 running scripts are the cause to all this...
    I'm using a Trail Renderer, with Time as 30, and Vertex Distance as 0, i tried setting it to 0.1-0.2 but it
    a.looks bad
    b.still killing my computer

    how do i keep the computer up and running?
    this is probably a noob thing to say, but how can Crysis 2 run on my PC on full graphics and this Empty scene with 10 missile crash it all down?
    I know its less about graphics, but anyway, how to stop it? in gameplay there should be more than 100 missiles running in big fights and this is already collapsing at 10?

    P.S sorry for posting this in Scripting Forum, I honestly didn't find a forum matching this question(Really, There should be an "Editor" forum or something like that)

    cheers

    Yair
     
    Last edited: Feb 10, 2012
  2. Whatbadguy

    Whatbadguy

    Joined:
    Apr 10, 2011
    Posts:
    165
    You're likely having problems with how many particles that's being rendered, probably from smoke trails and whatnot. I would use trails with a single texture
     
  3. jsipich

    jsipich

    Joined:
    Feb 3, 2012
    Posts:
    87
    As ThatBadGuy said it is more than likely too many particles. Also - can you elaborate a bit more?

    Does this happen after building the app or only when playtesting inside Unity? There will be considerable performance hits when inside the editir.
     
  4. yair1221

    yair1221

    Joined:
    Sep 28, 2011
    Posts:
    39
    well, it happens both in editor and in build
    and i dunno about to many particles, there aren't that much, really, there's just the missiles, and eight engines of the ship, each one is made out of a single texture, with an emission of about 50, which seems kinda standard...
    the missiles, as said, are a trail renderer, with one texture...i still dont know how to solve it, now the smoke trail only lasts for like 5 seconds and ive managed to spare about another 15 FPS, so now im on 30 FPS when I have 100 active missiles in the scene
    besides, the way i see it, models are alot heavier for the computer to calculate, and my scene is bloody empty...
     
  5. Whatbadguy

    Whatbadguy

    Joined:
    Apr 10, 2011
    Posts:
    165
    Got an idea how much vertices are being rendered through the stats box in the Game window? If it's not that, I can imagine that running 100 missiles all using physics forces could be your problem.
    If you're using physics you should consider translations.. If not, I dunno what else to tell you.
     
  6. yair1221

    yair1221

    Joined:
    Sep 28, 2011
    Posts:
    39
    wow, the missiles added about 150k verts, and if i would be adding more objects to the scene it will probably be something like 500k, how the heck do i solve that?
    maybe trail renderers are heavier than just particle emitters?
    but i cant draw a straight line with a particle emitter, there is always a halt in the sequence unless i use the same material 5 times and an emission of about 5000 :p
    thanks BTW ;)
     
  7. znoey

    znoey

    Joined:
    Oct 27, 2011
    Posts:
    174
    I agree with many of the others posted already. It sounds like your hitting either the particle limit or the physics limit. Rendering the models isn't really that huge if your using prefabs but rendering the particles could be killing you if your using more than say 20-50 per emitter. The model size matters but its probably.

    You may not know this but scaling, rotating and rendering a particle plane is pretty expensive compared to drawing a static model at a set position. Actually graphics and rendering is the most expensive part of games as a pretty general rule (AI is pretty expensive too...).

    Pooling the particles is probably a good idea to avoid creating and destroying memory on the fly, but I think you would need to write that yourself and you probably wouldn't gain all that much doing so anyway. I could help you get started with some of those if you needed.
     
  8. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Crysis 2 actually is optimised up to the eyeballs, and isn't as high poly as you'd expect. There are hundreds of optimisations the engine / developers did.

    Some of them would be having one particle system, with one draw call, for everything that is going on, instead of hundreds of little separate particle system. They would be using highly optimised shaders as well as batching everything in sight - probably dynamically too.

    You'll find if unity is treated right, the speeds are really fantastic, it is not an engine you can just throw things on and expect AAA quality without a little effort. So please me a lot more detailed about your problem, perhaps include a webplayer and some more stats.
     
  9. jsipich

    jsipich

    Joined:
    Feb 3, 2012
    Posts:
    87
    Is this missile something you've created in 3DS, Maya, Blender, etc? My friend was just toying around with a few models last week and "forgot" to load the downsized model (with about 10k polys) and instead loaded his fafillion-poly model - so he had issues just plopping 1 character body down, lol. I do similar mistakes when producing audio. I had the green light on finishing a remix for a record label and wanted a quick turnaround from concept to master - of course - i didn't exactly remember to finish moving certain freq's around the mix to make room for the leads - I'm like "why does everything sound like mud?". Disable out, enable aux bus, etc. Just quick mistakes like these can leave your head pounding haha!

    Anyhow - I can't see a stream of particles causing all that if they're pooled... but too many particles + an insane amount of poly's on a single model instantiated a bunch of times will kill anything right quick.
     
  10. Tseng

    Tseng

    Joined:
    Nov 29, 2010
    Posts:
    1,217
    That pretty much sounds like your "Min Vertex Distance" is very low (like 0.1). Try to increase it. The other factor is "Time". The higher the time and the lower the "Min Vertex Distance" the more poly/vertex will have to be created to make a smooth trail. So depending on the scale of your game (i.e. distance of the missile to the camera) you may reduce it to 0.5-5.

    The higher the Min Vertex value, the more "edgy" you trail may look but the performance will be much better.

    Also, for mobile platforms (if you ever aim for it): Trail renderers don't batch. So if you get 10 missiles, it's 10 drawcalls, not 1.
     
  11. RingOfStorms

    RingOfStorms

    Joined:
    Oct 23, 2010
    Posts:
    584
    Bit off topic but how do you save a low poly mode in Maya or blender. Never seen an option for that.

    For the missile problem I would suggest cutting down on the particles and making sure that your not using physics, as many computers crash from to much physics. Translations are fine when you know how to use them.
     
  12. jsipich

    jsipich

    Joined:
    Feb 3, 2012
    Posts:
    87
    Optimize modifier, face threshold, etc. A few ways for each program. Then adjust from there in case deformation occurs.