Conversation
…ips. Current Animators and clips are temporary
…ted EnemyTest anim
…criptable object to GameManager object
…ut implementation
…st adjust game scene size though?
…he actual animation name
| private void ActivateBullet() | ||
| { | ||
| GameObject nextInactiveBullet = GetNextInactiveBullet(); | ||
| GameObject nextInactiveBullet = bulletPool.GetPooledObject("Bullet"); |
There was a problem hiding this comment.
Strings in c# are allocated in dynamic memory - or the "heap". Every time you call this function and pass in a string like "Bullet", it'll create a new string in memory and allocate it onto the heap. Over time, this will call the garbage collector to run, which is an expensive action. Since this function will be called numerous times, it will be best to pass in a cached variable of the string.
| int numberOfEnemies = waveConfig.NumberOfEnemies; | ||
| for (int i = 0; i < numberOfEnemies; i++) | ||
| { | ||
| GameObject obj = enemyPool.GetPooledObject("Enemy"); |
There was a problem hiding this comment.
See my other comment about passing in strings
|
|
||
| private void Fire() | ||
| { | ||
| GameObject nextInactiveBullet = bulletPool.GetPooledObject("Bullet"); |
There was a problem hiding this comment.
Same comment about string passing
|
My main thought of how the current wave pattern works is that it gets the job done, but can get hairy if we start to think about future proofing it. Pros: Cons: Personally I would like you to take a look at how to make it work with math. You can probably make it equally pretty - if not better with simple math and easing. To answer your question about complex paths, it would look like the same equations we learned from school: You can set X as time, use Time.time or Time.deltaTime Straight Line: y = slope * x + (y-Intercept) Depending on what pattern you want, you can just google an equation and plug time into X and you should get your movement patterns. You probably shouldn't use animation pathing for a number of reasons - but the main one is that it's inflexible, and if you need to make changes later, it will be much harder. Multiple Waves: Bullets: I think overall you'll need to think about how can I make this clean with the least amount of code possible. Remember that when you make something work in code, you're only halfway there since you have to clean it up or see if you can make it better. Always be thinking if you're going to be confused or kicking yourself in the future when you're coding things. I know this isn't meant to be a long project, but it's good to think in this mentality. Let me know if you have any questions! |
Okay, in summary:
Questions that I have:
Thanks for helping out so far, sorry this past week or so has been pretty slow with adjusting to school schedule and trying to change all of my classes.