Hello everyone!
There is the next part of our devblog. This week we work on object pooling system, new type of units, fixing some bugs and one more thing, but its not ready yet and we cant present it right now :(
1. Object Pooling
If you are familiar with Unity you know that you can spawn object in this way
public class ExampleClass : MonoBehaviour
{
public Transform prefab;
void Start()
{
for (int i = 0; i < 10; i++)
{
Instantiate(prefab, new Vector3(i * 2.0F, 0, 0), Quaternion.identity);
}
}
}
This is a very easy and simple way, it may suit you if you have few objects in the game, but if you have 5 - 10 units per wave, a lot of projectiles and etc, then this will down your framerate very much.
Instead of creating objects every single time I find object pooling the best solution for this problem. In short, instead of spawning objects each time, you use pre-spawned ones. It will give you a high performance boost, cause you dont need to spawn object at runtime anymore. Of course, a situation may arise when the previously spawned objects are not enough. Then the pool system will create the object that is not worth it and add it to the shared pool. Pooling is also pretty easy to use. For example, this is the sample code from our game
//Get unit from the pool
EnemyMeleeController enemy = PoolManager.GetObject(units[i].unitName, portal.position, Quaternion.identity).GetComponent<EnemyMeleeController>();
But of course, your solution may differ from ours ?
There are some useful links about this:
- https://learn.unity.com/tutorial/object-pooling#
- https://www.raywenderlich.com/847-object-pooling-in-unity
2. New type of units
At this stage, we have implemented only two types of units: Archers and Infantry. This week we have implemented another type: Mages. It is similar in implementation to archers, but with some differences. Some types of mages are attacking, while others are supportive. We will have different types of mages in our game but now we have only fire mages. The reason for this was the difference in FX, where we dont have any experience and after several attempts, we did not have time to finish them to this moment, even FX for fire mages. I believe that after some practise I will do this ?
We also implemented fire mage in current gameplay, but as I say earlier we dont have FX for showing battle part
3.Conclusion
This week was not the richest in new functionality, but we learned some useful things. We also have some features which we want to present in this blog, but they takes more time than we expected and we didn't finish them in time. The next part promises to be richer in new features that we can show you ?