Wednesday, November 30, 2016

Project deadline passed - new deadline

OK, December is here, end of November, so game is released now?  No, release did not happen.  It's not all doom and gloom, I am close, but I'm constantly finding problems, and while they are now mostly behind me, I didn't even get to finish some mandatory features.  So I am going to extend my deadline by a week to fix up last minute bugs, and add the last few features.

This last couple of weeks has been yet another solid reminder of what difficulty AI, animation and physics is.  I noticed people saying this about sports games when I started the project, but really now understand it.  As they said back then, if I just made game X, Y or Z, there would be so much less AI, so much less crazy animation combinations, etc, etc.  Yes, I once again had a really tough time of it getting through various crazy bugs and conditions.  Since I had many repeated issues, I'll mention the high repeat ones:

  • Attaching AI script files to avatars.  My AI is built script by script, so rather than a mega AI script, I have one for contesting the ball, one for getting to a contest, one for leading, etc, etc.  One of the biggest problems I keep running into is I just haven't added a script to the player avatar.  It starts off with watching the AI do something really silly, and thinking I have to fix that.  Then I try to work through the script logic, seems like it should be doing the right thing.  Perhaps the entry logic is incorrect and the logic never gets run?  No that looks OK.  Finally, when I can't give a single reason the logic isn't firing, I realise the script isn't attached, therefore not even running!  It's the easiest thing in the world to fix, yet has alluded me probably a dozen times and caused a lot of wasted dev hours.
  • Floating targets.  Leaving physics to Unity does some weird things that aren't game friendly, so early on I decided to tackle it myself, but doing it yourself is a major pain too.  One of the issues I constantly stumble on is players floating away or falling through the earth.  There is nothing that takes you out of the game quicker than seeing someone runs towards a spot 2m above the ground, or sinking through the earth, or someone rotating on a 45 degree angle to the earth (eg they should fall over doing this).  I have little of this happening right now, though I've had to temporarily disable bumping, which I really want back in, so more work to happen, eg what do I do when someone is bumped mid jump, they need to still land again (currently they idle in mid air)
  • Timing a target.  I knew this would be painful.  The ball is flying in using gravity etc, and we need to jump to meet it.  At first I programmed it to just mark if the radius is close and we are closest, but lately I got a real trigger working on the players hands, where they only marked it if their hand got to it first.  This works pretty well now, but was a huge effort and is still not 100% yet.  When it works, it is very impressive however.


So, with the deadline done, was I just a few bugs short?  Not really.  Every day has feel like 1 step forward 2 steps back recently, and it's worn me down too.  As an example, in October, I could mark a ball, go back to kick at goal, and go to the next play after kicking a goal, with the score ending up on the scoreboard.  It was rough and buggy, but all that worked.  In the last few weeks, I have struggled getting a mark.  I have broken and just recently fixed the ability to get back to kick a goal.  I have broken and just fixed the ability to have another play after the first.  I have broken, and is still broken, the ability to even kick a goal, though to be fair, this is a new game mechanic I've been working on.  And then there were bugs!  Finally by the deadline, I had patched most pieces together, and to be honest, most stuff is coded pretty well, so I should be in a good position to use this code as a base, not retrofit 90% of code after beta release.  I have a few fluffy things to finish off with, like celebrations, crowd, umpires, but even some of this I've been working on.

I could probably get the beta "finished" by the weekend, but I'm giving myself another half a week to add a few features I really wanted from day one.  The game itself won't have any content outside of playing, so I want the beta to feel a little more than I just got something working, I want it to feel like my game.  A couple of the features I've really looked forward to adding is AI around celebrations or crowd, where the players react more real depending on the situation.  It's annoying to play a sport game and see someone do a massive celebration 10 goals behind in the last quarter, or the commentator get excited, eg. in that exact situation commentator AI should be choosing between things like "a small ray of sunlight on an otherwise gloomy afternoon" or "that's not going to affect the result today."  But instead they say things like "he's just really firing today," completely out of context for the game.  Or even better (and with unlimited time to code a commentator AI), it would take into account things like the season.  "That won't change the result... but percentages are very important late in the season and being in the mix for finals" or "that won't change the result, but they'll want to get a bit closer to make sure this result doesn't ruin the start of their season."

My point is, I don't want to be putting out a product that just barely gets the job done, I need to build some strengths where I can, and hopefully add something positive to the playing experience.

So now that I've breached my November deadline, I'll add roughly a week on until I reach the objective of be able to play a basic game with minimal bugs, and perhaps a few nice extras in the game play that aren't yet.  I'm still going to push hard to have that done by Wednesday 7th December.

Sunday, November 20, 2016

2 weeks remain - animation animation animation

With less than 2 weeks left, I should be looking at putting some polishing touches on this game, but am instead running circles around the ball, both metophorically, and in some cases, that's what the actual player is doing.

I'm making progress, and at some point, I would have had to do what I'm doing if I wanted a complete game, I guess I figured I wouldn't need to go through this hassle in the 12 week project part.  On paper, the game seems to have changed in very small ways the last 5 weeks, possibly going backwards in some ways.  But I had reached the abosolute limit of my hacky animation controller, and it was taking me hours to make a small change, because it would break something else in the process.

OK, so the things I've been up against recently:

  • Animation.  At one point this was a simple little thing, that just needed slight tweaking to finalise, at least in my mind.  A better way to actually look at it, it is a monster.  Unity and Mixamo kicked my ass for a good few days.  There is generic model/animation and humanoid model/animation in Unity.  By default the Mixamo stuff comes out generic, but that doesn't work well with Unity transforms.  Google helped me realise I needed to change it to Humanoid, but that just plain didn't animate.  The answer alluded me brilliantly, you need to find the base avatar, set that Humanoid, then change every animation.  Next, the animations now work, but look rediculous, like when running, the animation itself looks great, but when rigged to a humanoid avatar, limbs just go in weird directions, making it look like they are in the process of turning, when they are going dead straight.  I have no idea how I resolved this, but I had 50 attempts before something just worked.  And apart from that, I found the more animations I got, the more complex and buggy the Animator became.  It's frustrating debugging the animator, seeing the flag to start jumping is set, and the animator is completely ignoring it, when the only thing I've set is to jump when that flag is true.  This just went through a complete overhaul.  I've now ripped the entire original controller out, and replaced the animations with sub states, where the main state is either idle, moving, jumping, bumping, spoiling, but under each of those, there are substates, so under moving there is running, walking, running backwards, etc.  This works well, and whats more, adding another animation is childs play now.  In terms of content, I've worked through a few types of marking, I've added bumping and walking.  Animation is not complete, but it's definitely in the best place it's been for a while.
  • I also finally managed to get some colour on my characters.  I heard an interesting comment about game design, and saying it's easier to get excited about a project if it's looking good.  That is it's all well and good to say you should be able to make the controls and physics work while the characters are just cubes, but it's easier to get excited about it if they look like Aussie Rules players.  I had no idea how I was going to do this, but Adobe stepped in for me with a free preview tool called Fuse.  Fuse allows you to define a look for a 3D character, from skin, to hair, to body shape, to clothes.  I used this to get a sort of Aussie Rules type clothing, but there is no colour editing in that tool.  The final edit was a little hacky, each clothing is an object, but has several files to render it, some for the mesh, some for the material qualities.  I opened the diffuse map in paint.net, reworked the key areas to be like teams tops, shorts and socks, and now have proper looking players.  Not perfect, but not bad at all.


So, I'm up against it for time now.  A lot of things seem to be on the too hard list now, and just getting a non-buggy gameplay could possibly soak up most of the remaining time.  There is no point backing down though, I am going to push hard this next week and a half, and just see how much I can squeeze into it.  With a little luck, I can get a decent product up and running, and have my solid base to work from.

So things to look at this week:

  • Finalise the bumping, spoiling and marking.  This will not be perfect, but I have to call it quits somewhere, and it at least has to have bumping and some level of marking/dropping a ball.  Spoiling doesn't have a good animation, but again, I don't have time to learn 3D animation creation, so I have to work with what I have.
  • Finalise the decision making of the defenders
  • Organise the player positions at the start of every play
  • Finalise camera positions


Nice to haves if I can squeeze out a couple more hours:

  • Umpires and crowd
  • Noises
  • Music
  • Settings (eg. sound on/off, less graphics for older phones)


The list of things I'm not going to attempt by next week is too big to bother listing, but it's essentially down to getting a solid base by next week, and then I'll try to look back and re-assess everything that I've done.  I have to then look at what other projects I want to play around with next (the list is growing), and whether there is enough in this product to bother continuing with, or whether to just put this down as a learning project.

Tuesday, November 1, 2016

Wednesday update #7 AI Physics IOS

It's been 2 weeks since a Wednesday update, AI, AI, AI.  Well, to be fair, AI and physics.

As November fires up it's engines, the end line looks exceptionally close, which is good and bad.  On one hand, it will be good to see an end to this project, on the other there is nowhere near enough time left!

Here is how the last two weeks went:

  • AI.  Getting the first two players to try to mark properly has been kind of tough, and I'm not even sure I'm going to fully get it by release either.  I've spent about 2 weeks working through some physics/AI/animation issues here, and it's a slow process.  When there are problems that don't make sense, you goto to debug the problem.  Here, I've had a big problem, as the debugging often freezes up after a little while, restarting Unity and VS are sometimes needed.  I'd say in every dev session, this has happened at least 5 times, and it's realistically 10 minutes gone once you finally give up on it, restart everything, get the code back to the same break point.  It's also just generally slow to get your head around these issues.  You can have a few triggers that might end up affecting a case, and if a certain code doesn't get hit, it could be because of something wrong in 3 different files, so knowing which part is not correct can cause problems.  A few big AI issues around contests have been looked at.  Right now, the player can decide if they have time to go for a big mark, or just run to a place where the ball will be lower to the ground.  If they get there in time they can pause and wait, if they don't get there in time they don't try to jump.  It looks pretty good so far, but there are a few really obvious missing entries.
  • Animation.  I've been meaning to have a little crack at animation editing, and yesterday did some.  I had a good AFL like marking animation, but it was too slow, so the player goes from running full speed, to stop, to slowly build up to the jump.  To fix this, I duplicated the mark animation, and set the starting point of the animation to be as he's about to lead into the jump.  Now he runs toward the contest, and just launches into the jump, it looks and works well.  The animation controller allows him to go from idle or running to jumping, and has kicking etc too.  So far so good for animation, there is a tonne more to do.
  • Physics.  I say AI a lot, but really a lot of it is physics.  Most bugs are physics bugs not AI bugs right now, like right now when the player completes a mark, they make a crazy looking semi-arc back to where they launched for the mark.  This will be easy enough to fix, but there are random crazy looking things everywhere.  A big thing I've looked at is timing the player to meet the ball.  This is definitely a science, and the problem is a ball approaching really quickly, and a player jumping at the same time, the timing is not quite there for me to perfect this unfortunately, but I have it pretty close now.  I've managed to find the players hand object, so part of a mark is getting that hand close enough to the ball object, and claiming it, which I do by making the hands it's parent object.  I got the code to a really good place yesterday.
  • IOS.  I got a mac, and ordered a dev license, so have nothing but a little pain in front of me before I can develop on ipad.
  • Other.  I did get a couple of other things in.  Grass.  This has been a pain, and at this point, I think I've ditched it, and gone with my weird looking terrain.  One of the big problems is getting the grass short enough.  Unitys built in grass looked fine at 1m high (in my game), but when 10cm high got an extremely blotchy field.  I found a couple of good examples of better things to try, a tree stripped down to look like grass and then use the tree option on terrain.  This worked fine, but again was near impossible to get looking right for low grass.  I had a rest on this, and a breakthrough the next day to use an image with just a small height grass, ie lots of space above it.  This worked for both methods, but... using the grass terrain, it looked fine from below but just looked awful from above, and chewed through my frame rate once you tried to display the whole field.  The tree method wasn't much better.  In the meantime I'd been learning a bit about shading the grass to look more realistic tone, and essentially just kept the same field I had, but toned it better, as well as toning some other elements better.  This gave me a decent result, and I can still get my high frame rate, so this is pretty much me for now.  If the project goes well enough, I may need to invest in a grass asset from the asset store.  Other things were minor.  Got some advertising boards done, needs to be finished off though.


Overall, the leading for the ball, running, jumping, marking all looks good in a very simple example.  Of course AFL is not simple, and thus the big problem I'll have going forward.  I was watching an 80's game on TV, and just noticed some things that you really can't get an AI to do, as an example, the ball was kicked to a contest, and two guys wrestled near the target point, as my game will hopefully do.  Another couple waited patiently in case it wasn't marked.  Then a player from the other direction ran back with the flight and took an amazing mark over the two guys wrestling.  This is where AI gets really interesting.  Now lets say I see that, and say, yes I guess that is a possible move someone could make.  It can't happen every time a player is there, it would spoil the game.  Yet it was mark of the day, and what fans really love watching about the sport, the one off big moves.  I need to think about this somewhat.  Perhaps I could chamber 5 or 6 "exciting" moves, and when a chance to use them comes up, I randomly pick it like 1 of 5 times the situation is possible the player goes for it, and maybe 2 in 3 they stuff it up anyway.  Food for thought.

But way back here in current reality, I have a release to work towards, and a lot of much bigger problems.  This week I'll be aiming to:

  • Add non-jumping marks, eg player just puts there hands up and marks without jumping
  • Add spoils.  The worse off player should try to spoil the marking player
  • Add more physics logic to a mark.  Right now it's just proximaty to right hand, but it should be the spot in between both hands, and given I don't have crazy good animations, probably need to accept marks if it's slightly under the hands, but exclude marks if they are too high or low
  • Bug fixes in those general areas
  • If I get sick of AI/physics, probably time to start working on the player uniforms too, finish off the advertising banners, finish off the stands properly.  


Weeks to go!