Welcome fellow Citizens to episode 9 of Bugsmashers!
– Ship animations weren’t playing after integrating some new CryEngine improvements (from CryEngine 3.7).
– Took quite some time to narrow it down.
– In Mannequin, state machine for controlling animations on vehicles and players, there is an update loop that is supposed to go through each scope (Mark compares a scope to a layer in photoshop – for the purposes of these notes there are scopes for each part of the ship that can play an animation).
– With the attempt to get into the Gladius, you can see that the Canopy and LeftLadder scopes are trying to play an animation and sound but never update.
– The update loop had a bit value that was out of range due to a small error in the code.
– Mark fixed this tiny bit of code and the animations started updating properly again! Huzzah!
– Finding the tiny piece of code that was the problem was the biggest challenge.
Mgerno1 asks: How do you avoid writing spaghetti code which I find in particular hard if you are under some time constraint? Is there a code review? How do you guys tackle performance problems.
MA: So, to answer your first question, spaghetti code is a tricky thing to solve – especially under crunch. I would recommend, at least what we do here, is if you’re going to have to write a bunch of ‘if… else’ statements, you’re basically writing a state machine. Look up state machine but those are the best thing ever because you could be – you don’t have to write this big block of spaghetti ‘if… else’ statements and what happens if you miss a statement? Oh no, now everything’s broken. Write a state machine because you can have an enter, exit, and active and then you just keep looping and then you transfer from one to another – you can ensure that your variables, your states, your logic flows. So, look up state machines, those are the best things ever.
Code review… code reviews will help but if you’re under crunch and everyone starts throwing in code reviews sometimes bugs slip in. They do help narrow down some bugs and they also prevent bad things from happening or people touching things they’re not supposed to touch but don’t use code reviews as the ultimatum “this will solve everything”. It’s just another tool that has its pros and its cons.
‘How do you guys tackle performance problems?’ Profiling, profiling, profiling! That is the biggest thing you can do. If your game is running slow… why? Throw in some profiles, see where things are slowing down. Use some performance tools. Try to narrow down the sections of code that are causing you the trouble because those are the areas that you want to optimize and get better. ‘Oh, you’re loading in a bunch of geometry and that’s causing your game to slow down?’ Maybe look into streaming. Load all the low res stuff first before you get the high res stuff. Stuff like that.
Mark, great videos always. Thanks for taking the time to record these for us.
MA: Any time!
I do have a question: Is coding something you would advise going through a 4 year CS program to pick up or is it something that you can learn on your own and still be successful with? Speaking as someone in their mid 30s who already has a few degrees, but not a CS degree, I’m hoping the latter is possible.
MA: So, that is kind of a tricky thing because I do know people who have gone through the 4 year program and they have wonderful jobs in the programming field and I know people who have done CS degrees who do not have engineering jobs. I know people that have never gone to school for it who are in the field and vice versa.
From what I’ve seen, if you know how to program well and you’ve done personal side projects with a crazy amount of interesting features… so if I’m going to go for a game job, so you have a background of… maybe you’ve made a bunch of games and maybe you work with a few other people to maker some indie projects. Just getting a degree won’t help me. Not having a degree may or may not help. It’s kind of a tossup. You know, if you’re going to go for a AAA studio and you have no background or nothing to show, then they’re going to want to see a degree just to make sure you know what you know. So, I would say a degree will help but what will help even more is getting a lot of personal projects up and running. Join an indie group. Make things on the side and build stuff in your spare time, because a lot of companies – especially this one – love to see personal projects. Because, if you just do things from one job to the next it’s hard to say what skills you have and if you could see a lot of possible things that you’ve done in the past, that’s a BIG BIG BIG thing. So, I would suggest: Try doing stuff on the side, see how it goes and if you think you need a little bit more, go for the 4 year. Do what you think will help you become the best damn programmer there is.