- Home /
[Solved] How to do one draw call out of a rotating coins?
Hello,
I have coins spread out on the level. Now the coin has polygons and the coins belong to the same prefab. Now whenever I use the coin it recognizes as single draw call.
I am avoiding static batching here as the coins are rotating on Y axis.
My target here is to use as many coins as possible on the level and they have to just give one draw call. When the collider interacts with the coin they disappear and as level loads they appear.
Is it possible? Your help is appreciated.
thank you & regards,
Karsnen.
what is this? 2D ? if so just use 2DToolkit and it's all done in one draw call
Answer by Karsnen_2 · Nov 25, 2012 at 01:12 PM
FInally I did find out a solution.
Lets say that we have numerous coins scattered around the environment and all the coins have a mesh and they rotate by themselves on Y axis.
I have two scripts.
CoinManager.cs
CoinReceiver.cs
I create delegate and event system. I declare it public and the event as a static on the CoinManager.cs script. For the coin to rotate, generate a Quaternion with Y angle rotating. Now delegate passes this Quaternion parameter.
On the CoinReceiver.cs, I use OnEnable and OnDisable methods to activate and deactivate receiving the events. I have a method which would HandleTheEvent(Quaternion Q), which just assigns the quaternion to this.transform.rotation.
Hence with this, I was able to achieve complete dynamic batching no matter how many coins to have or you multiply during runtime. But the downside of this method is that, the coins will all rotate at the same angle.
I wish to attach the scripts in the future, as I do not have it with me right now. I hope it helps for anyone who is looking for this answer. If not kindly buzz me.
Later.
Answer by Griffo · Nov 24, 2012 at 05:39 PM
you can setup a Occlusion Area (Pro Only) to help cut the count down
Answer by sirival · Nov 25, 2012 at 01:36 PM
Maybe you will find this link useful http://answers.unity3d.com/questions/36050/why-isnt-dynamic-batching-working.html