I have around 300-500 enemies that can be active at a given time. Each enemy has needs to know the spawn point for its bullet. They also have multiple spawn points based on the type of attack. What would be faster (as in more optimized): Placing “spawn” empty children into each enemy which acts as the spawn point, or to have it calculate the spawn point for every bullet fire? I ask due to the amount of GameObjects this would create.
EDIT: On a side question, does anyone know if a box trigger is faster that a polygon trigger when used in mass numbers?
The problem with a Vector3 is that it needs to be updated, meaning I have to calculate it upon a bullet firing. The advantage of using a transform is that moves with the object. I suppose I could do something like:
hippocoder means that you run a test with each method, and see which one runs more efficiently.
You load on the number of times you’re doing this (test 1000, 5000, 100,000 enemies) and see which one runs faster.
Unity has a profiler built in as well that makes this even easier.
But… it is pro only.
You can still profile without it, just not as nicely. A simple way is to just use the DateTime object to track time. Or you could even just watch your framerate and see which is better.
There are also 3rd party options as well that range from free to 30 and 50 dollars.
Honestly I don’t see either being all that expensive.
If it was JUST ME I’d use a vector because it has a smaller memory footprint. But because I have to design with designers in mind, I’d probably use a GameObject so that my team mates could easily just plop down a GameObject and modify it.
Using a vector would be easy as you can just call Transform.TransformPoint to quickly transform the point to world space from local space. It’s not that expensive, and you won’t be doing this EVERY frame.