Hello! Today I'm going to reflect on my processes for Game Development and how these can be improved.
Tasks/Notes
One of the issues I've had is that I've started at a Unity project without any resemblence of what even to do with it. This usually occurs at the start of a project when there is a blank slate, and when there is confusion about what to do to build the project up from scratch. The result of which is a tendency to become distracted and to do other things instead like browsing YouTube.
One thing I've tried doing to solve this is by making to-do lists of tasks, however, another issue I've had is writing notes or to-do lists that are too vague in content and not easy to understand in handwriting.
To fix this, instead of writing down notes quickly like I used to, a better method would be to sit down and think of what needs to be done for a particular task, and then write down the steps to complete that task. Take shooting a bullet out of a Tower for example. What are the steps I need to take to complete this task?
Slowing down, creating step-by-step instructions and writing in a slower but more readable way helps to get an idea of what needs to be done to implement something. The first few steps are very easy:
Comments
Another issue I've not really considered yet until recently is comments. I previously didn't use comments that much, usually because of a sense that I didn't need them. My projects are usually solo or where I'm the sole or main programmer and where sharing code was not usually needed, however, I recognise that comments are very useful when looking back on code, when sharing code with others or when figuring out what to do to implement lines of code. Take shooting bullets again for instance, what needs to be done in the script to shoot a bullet?
Here, I can break one big task (shooting a bullet) down into more individual taks like getting a target and shooting. Then I can abstract further in a Method, writing down tasks for that too. What do I need to do in ShootBullet()? Then I can think of the things I will need for this function. In this case I will need 2 variables, the speed at which the bullet fires and the speed between bullets. As with a lot of things in life, it often doesn't go according to plan immediately. Here I notice 2 problems, 1 is that the bullets are moving very slowly, a consequence of the time.DeltaTime I used to multiply the bullet speed, the other is that it is shooting a lot of bullets a second, which causes some slow down. The solution here is to, in the Unity inspector, to increase bulletSpeed by a lot.
The second problem is also easily recognisable but needs some more code to fix, the script is shooting a lot of bullets per second instead of shooting one, waiting for the speedBetweenBullets and then shooting, the absense of a speedBetweenBullets in the script above is an obvious indicator of what I've not put in yet.
I knew how I could potentially fixed it so I went ahead and implemented it: I changed the ShootBullet method to a Coroutine, I introduced a isShooting bool and added it to both the if statement where ShootBullet is called and the Coroutine itself.
Now the code will check to see if ShootBullet is false in addition to seeing if there is a target, if both is true, the Coroutine is called. In the Coroutine, isShooting is immediately set to true to prevent StartCoroutine from being called again, and at the end of the Coroutine after the yield return line where it waits for bulletSpeed, isShooting is set to false so it can be called again.
It's getting there! But it still needs some work. The 2 things I notice are that the bullet isn't moving exactly to the enemies location and that its still too slow. I check the TowerShoot code and notice that I've set AddForce with target.up rather than transform.up.
To try and fix it, I turn offset into a variable than I can edit in the inspector and then I play around with it a bit, eventually I find that -90 works well. However, the bullet is still too slow and it only fires 1 bullet which is a little strange.
This is bizzare. I start to think that I may have to redo the script that finds the nearest enemy, which I'll do with some Google searching and reading.















