Sometimes I can code “Good” but other times I can code “Really bad”.
While I am sure that this is only a result of inexperience, it doesn’t help when I am surrounded by 18 – 20 something kids that already have several years of coding experience on me.
What I seem to lack in aptitude, I make up with attitude. I will doggedly try and hunt down solutions on Google and am slowly building up my knowledge base of what to do in certain situations.
I think an example of when I code “Good” is this piece of code I used for the step sound effects:
public Camera myCamera;
private float stepTimer = 0.0f;
public float timeTillNextStep;
//Lists of audioclips
public List<AudioClip> stepSource;
void FixedUpdate ()
stepTimer += Time.deltaTime;
if(Input.GetAxis(“Horizontal”)!= 0 || Input.GetAxis(“Vertical”) != 0)
if (myCamera.enabled == true && stepTimer >= timeTillNextStep)
void GetRandomSound (List<AudioClip> randomClip)
int j = Random.Range(0, (randomClip.Count – 1));
stepTimer = 0;
This is a piece of code that works for all of the different models in my game and cam be set up for different numbers of step sounds with different spaces between steps.
While I haven’t figured out how to overcome the fact that the model is jumping, I believe it is good and I am proud of it.
What I am not proud of is spending so long trying to “bastardise” the Unity 3rd person controller and camera trying to get a decent character controller operational. I spent so long trying to get this to work, poaching different scripts for online and trying to fix it with fencing wire and tar, that it would have been easier to have just followed one of the many tutorials online. I would have a better idea of how the controller works and what goes into making one.
The other thing that I am not proud of, is the amount of time I tried to get the raycasting or spherecasting to try and work. I wasn’t sure that it was the best design decision in the long run, but I just couldn’t get it to work reliably and effectively every time. I could do it with great effect in the Second assignment last year, with raycasting enemies and consistently getting “head shots” at various distances, I just couldn’t get it to work in this project. I tried so many combinations of start points, directions, formulating rays prior to the raycast, I couldn’t make them work, especially at a greater distance.
At the last minute I was able to work in an effective way of merely swapping between the characters that didn’t use the keyboard but relied on mouse buttons, or in the event of a controller, sensible buttons to make the change.
It seems that, in most cases, I try and find the hardest possible solution to a problem, and that is so wrong with coding. Mt team mate came up with a simple teleporter for the small minion in one of the levels that called for two small minions. The solution was so simple that I would have overlooked the answer. It was as simple as saying the the transform now = the new transform position at the other teleporter. I was thinking of various ways of destroying it and instantiating it at the other portal, but was then worried about that breaking the GameDirector.
It almost seems to me that “lazy” thinking seems to pay off with programming. What is the easiest way to do this action. I know it probably isn’t “lazy” thinking, but it seems that way to me at the moment, probably because I am trying too hard. Perhaps it is because I am thinking on a level that is a bit above what I should be looking at. With the teleporter example, I was thinking how to move a gameobject from one point to another instantaneously. Maybe I should have been thinking how can I move this transform from one place to the other. The answers are always easier in hindsight, which make me think that a mix of experience and a change in my rational thinking will be of the most benefit to me.