AI! IK! Ok…?

Sep 082015
 
twittergoogle_plusredditlinkedintumblrmail

A few weeks ago while testing the game, I had to face the fact the AI (the artificial intelligence driving the enemies) was simply not good enough. It had become extremely bloated in terms of code complexity and yet was not quite delivering the quality I wanted.

So I decided to redo the entire game’s AI system from scratch, this time using a different behavior-tree technique.

It was a scary decision as during a few days the game wasn’t even playable; first I had to unplug all the actors’ “brains” and then I started again, slowly building up their new behaviors, piece by piece. I knew exactly what I wanted so I was able to get to the point rather quickly. But this time while I worked I hid away all the models, the animation, etc… and only used capsules.

Capsules are simple shapes that roughly represent the volume and orientation of the actors. Here’s an example with Tilo as you’ve probably never seen him before: he’s turned into a mix of a minion, a fire hydrant and a cucumber! 😀

 

(On the video you can see the capsule changing color depending on whether or not it’s in contact with the ground)

The result of this huge endeavor is in the span of 2 weeks I was able to redo and greatly improve the AI that had taken me more than a year to get into a flimsy “mostly-working” state. Except this time it is much more robust and I know exactly WHY it works the way it does.

So although the decision to redo the AI was a frightening one it ended up paying off BIG time:

  • The AI asset I use is quite visual (it’s called “Node Canvas”), so I can see exactly what’s happening in real-time
  • I was able to get rid of hundreds (if not more) of lines of codes, making the maintenance and expansion on the system much more manageable
  • The capsule approach allowed me to focus on the behavior itself without animation clouding the potential issues
  • The AI is now far richer than it’s ever been before and allows for really neat tricks

Here’s a bird’s eye view of what a behavior tree looks like. All the branches light up and change colors according to their state (as you can see in the inset picture).

ScreenShot 2015_08_20 11;43;59001s1

I have also finally come around to implementing IKs for the actors. What this means is the character’s feet are now actually hugging the ground instead of remaining up in mid-air on a virtual flat-plane.

It wasn’t too difficult to implement thanks to a great asset I found called “Final IK”. Integrating the system into the game’s pipeline was painless and it yields very satisfying results! Here’s a quick test video:

 

(Don’t mind the red cube, it’s just a debug visual for the AI’s target position)

You’ll notice the Rat is really pushing on his legs as he climbs up the slope, contrasting a lot with Tilo who is a much lighter and nimbler character. Your speed (and the ability to sneak) is your main asset in the game; believe me, you don’t want to let these guys get their hands on you, especially without wearing any protections!!

Anyway, that concludes this update. I hope you liked it! Please don’t hesitate leaving your thoughts and questions below… :)

  37 Responses to “AI! IK! Ok…?”

  1. Wow really impressive, the rat looks that scary! Thanks for the update.

  2. Very interesting!

    That rat definitively has a “weight” feel in his movement. Way better animation than a lot of games out there.

  3. Beautiful! Will the big ol rats ever pick up their pace and move faster than that slow walk? reminds me of Jason Voohee’s. hehehe… I do like that their large size and gait allows them to cover ground effectively, but it strikes me as odd to see him lag behind Tilo and NOT break into a light jog even…

    • Thank you Gumby-who-happens-to-be-an-evil-monarch (can I call you evilkinggumby?)! :)

      To answer your note (and it’s a good one) currently the Rats do not pick up pace. I have been considering implementing a slightly quicker gait when they actively chase you but haven’t done it yet.

      There are two primary reasons for that: the first one is it actually feels scarier this way. Because they are stubborn, relentless and you know they’re coming for you. For them to move quicker would feel more like a combat game (eg: Dark Souls).

      The second reason is… well it wouldn’t be as much fun. Because the game relies on you evading them (breaking the line of sight) and finding places to hide in the environment. If they were to move any faster they would just be on you that much sooner. Also there are quite a few interior environments in the game and within rooms/corridors the distances feel much shorter than the huge empty space in the video.

      Believe me, any time we’ve tested the game players were quickly panicking when trying to flee the Rats, even at their current pace! 😀

  4. Great update, Seith! Nice to see your attention went into the game’s finer details – that huge rat looked like it was really struggling! If Tilo remains stationary do his feet adjust to the different slopes (e.g.: standing on two different steps) – similar to Guild Wars 2?

    Cheers and well done!

  5. Can’t wait anymore to play this game!! :) It’s growing always much better.

  6. Wow that animation looks really sweet! And props to replacing such a core part in the middle of development. Was the previous solution an asset or written by yourself?
    Also I noticed this in some of your earlier posts: your setup scene already looks great with lighting, baked lights/shadows, DOF, probably color grading properly setup. Any tips for a Unity noob on how you achieved that cinematic look? Also are you using pro builder? Cheers :)

    • Hi Marc. Thanks! The previous AI asset I was using is called “Behavior Designer” and it’s actually very good. Plus its developer is doing a kick-ass job at support. It’s just that it is a bit less visual and I had a harder time using it than “Node Canvas”. A pure coder would probably hold the opposite opinion though.

      Regarding the look of the game I actually do not use anything baked (so no baked lights or shadows). Neither do I use Global Illumination. Everything is real time. The reason is I want things to remain flexible and have zero impact on my workflow. So anything that requires me to wait to see the result is out from the get go.

      I did try Pro Builder at some point but I ended up not using it at all. I prefer to block things out quickly in Unity using cubes and then export the geometry to Maya using “Export2Maya”.

  7. Looking might fine!

    What takes longer for you, the coding or the 3D/animation aspect of the game?

    Very impressive none the less :)

    • Cheers! Hands down coding is what takes longer for me. followed by character/environment modeling/rigging. Animation is more recreational; a nice break from all the coding. :)

  8. Looking fantastic as usual, really looking forward to this game. Does the rat’s actual speed slow down when going up a slope?

    • Thank you Stephen! It feels a bit like that but actually he doesn’t slow down. It’s just a visual byproduct of the spine IK pushing down on every step.

      • Maybe you have your reasons, but shouldn’t he slowdown? It should add realism and make a more noticable difference on higher slopes…?

  9. Wow this is looking Amazing so far! It is always astounding at how great of a game a couple person team can make, compared to the huge gaming companies. :)

    Your doing a great job!!! All that hard work really shows.

    • Thank you very much!

      To the topic of huge gaming companies, they usually have a lot of employees who simply do their job. But in the case of GoaT I work on it (and I know I talk for Paul and Cyrille) because I believe in it. Because it’s a passion. Because if I don’t work on it then the game will never exist. And this thought is all at once exciting, scary and rewarding. :)

  10. Really feeling the weight on the feet there. Nice!

    And I had no idea there was a node-based system for Unity. I’ll have to look more into it.

  11. Amazing! I guess 99% of people uploading submissions to greenlight would never, even if the game would be released on steam, redo the entire AI to ensure and improve the quality of their product. I can’t wait to play this, I never seen a developer making me trust into a game like you with all the details you give us about your work (it’s also very impressive, I’m glad I only have to buy it ;-).

    • Thank you so much, it feels nice to get feedback like yours when spending a lot of time implementing difficult features and fixing bugs… Keeps the morale up! :)

  12. I find it amazing that not only are you such a skilled artist, you’re also a clear-headed programmer with such high standards! What I know about code could probably fit on a small napkin, but I have heard how tempting it is, to keep applying bandaids to bad foundations 😛 An entire overhaul like this takes not just effort, but real dedication to the quality of your product. The fact it pays off is no coincidence! That’s what comes out of hard work and a great ethic! :) Keep it up, I love every little peek at the game we get!

    Also, liking this post’s title! 😉

    • Haha. Thank you for the compliment but I’m sure “real” programmers would be appalled at my lack of knowledge in the matter. But one thing is I can learn pretty quickly; so when I make mistakes I tend not to reproduce them.

      And since I learned how to code while creating GoaT I must have reprogrammed core features at least 4 or 5 times each; each time simplifying them and making them more robust.

      I’ve been basically building a foundation made of several little systems that can talk to each-other. And nowadays it becomes much more rare for me to find I have to redo one of them from scratch. Things seems to work together mostly well! :)

      Glad you like the cheeky title! 😀

  13. Tant de talents et de savoir faire. Je suis impressionnée et admirative. C’est un très beau travail. Je pense que cela devrait faire réfléchir de plus gros studios, incapables de mettre autant de passion à l’ouvrage. Je guette dans l’ombre l’évolution, et il me tarde de pouvoir mettre la main dessus, même si je ne sais pas encore si je dois le prendre sur Xbox ou sur Pc (choix cornélien). En attendant, je ne peux que vous souhaiter une très bonne continuation et de la persévérance.

    • Merci Catie! La version PC arrivera avant la version Xbox One et dependant de la qualite de votre ordinateur les visuels seront sans doute plus pousses sur PC.

      Et encore merci d’etre sortie de l’ombre pour exprimer votre soutien! 😛

  14. Hi Seith !
    I’ve been following the development of Ghost of a Tale for quite some time now. I’m really fascinated by this game, and I can’t wait until it’s release :) It seem really unique and really detailed (as you show it here with the moving of Tilo compared to the moving of the big rat). When I was reading this update, my girlfriend (who is also interested in this game) was just next to me with her pet mouse, and she observed,that Tilo’s tail was a bit shorter than that of a real mouse. I don’t know if it’s intentional due to clipping issues or something else, or there are mice with shorter tails ( I’m not an expert :) ) ,it’s just a small observation which I wanted to share with you. Still, I’m really excited about this game, especially it’s story. It’s really creative to make a fantasy-like world with mice and rats. Keep up the good work!
    Cheers! :)

    • Thank you for your feedback Clois! Yes, Tilo’s tail not being too long is to somehow alleviate penetrations issues with the environment. So mice tails in game are indeed about a third shorter than real ones. Your girlfriend does know mice!! 😀

  15. My gosh that IK asset is amazing, thanks for sharing that one!
    I’m currently learning Unity, and seeing this game as it progresses is simply bliss, it’s so awesome! :)

  16. Hi!
    The game looks great! I was wondering if there will be a demo sometime in the future? Can’t wait to try it!

  17. The game looks like pure magic. Godspeed! Looking forward to the Steam release.

  18. Hey Seith, sorry to pop an old thread, but I still hope old comments ding the inbox.

    If you are willing and able, just wondering a little bit about your character controller set up.
    It doesn’t look to be the CharacterController, and it too precises to be entirely physics based, but I have found that manually controlling an object throws collisions out the window. I would really appreciate a few words on the set up, or even how you conceptualized what you have going.

    Either way, your game and blog are very inspiring, I love pouring over images and videos trying to figure out how you did things 😛 One of very few games i am looking forward to.

    Cheers, Steven.

  19. This article will help the internet people for setting up new weblog or even a blog from start to end.

  20. Hi Seith,

    your character controller really looks awesome. Do you use root-motion?

    As Steven I would also be glad if you could share some insights to your character controller setup. :)

 Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>