Alternative to LineRenderer/TrailRenderer

Hello,

I’m trying to make some lasershots/projectiles for a top downshooter and I’ve found LineRenderer to be pretty nice for lasers/laser shots, however each LineRenderer will cause a drawcall, which is deadly in a top down shooter with high number of shots on the scene, so this will definitely kill performance on Smartphones.

So I need some replacement to the LineRenderer which will allow dynamical batching? Or a wait to make the LineRenderer work with dynamic batching.

I setup a multi laser shot (5 shots at once) but it’s causing 5 draw calls, even though they all use the same material. Any ideas?

Regards
Tseng

'A' drawcall? Out of thousands? Well, you could always write your own line renderer that works in a similar way, but with systems to make sure you only use one mesh per material...

Well, that's pretty serious. I would recommend using just mesh renderers and coding them so they stretch like a line renderer would! If your game is top-down only, you don't even have to worry about facing the camera.

I'm running into a similar problem, did you ever find a solution Tseng?

No, not really. I just went and made the laser projectiles as sprites and use 2D Toolkit to generate the atlas for it. However, this doesn't solve the trail problem

1 Answer

1

The performance of the LineRenderer is terrible. I have about 15.000 lines in my oculus rift app that are generated by script and it was impossible to keep the needed 75 FPS. But I found a better solution and now create them by myself with meshes and its lightning fast.

See this link to a great article to learn how it works: 3 ways to draw 3D lines in Unity3D

Two remarks to the article:

  1. In spite of what the article saysyou can indeed use the graphics class with unity free (Tested with 4.6)
  2. Instead of using DrawMesh calls in Update() I attached the meshes to game objects instead (with MeshFilter). That gives you more flexibility and seams to be just as fast.

Hope this helps.

Does graphics class work on iOS / Android?