Update 20: July 12th – August 1st
Alright so it’s not August 1st as promised but I’m not that late.
On the personal side of things, I just had the loveliest vacation in Colorado. I went with my sister and we had a huge road trip, saw Pike’s Peak, spent a couple days at the Great Colorado Sand Dunes (inspired by my favorite book) and generally just had a good time. I got to just completely relax for probably the first time since my Christmas week off.
I thought the week after that would be good for the normal schedule (besides move day) but I was pretty wrong. I got a fair amount done on Monday and Tuesday, but I’m still unpacking after Wednesday (when I thought I could write the blog) and only got internet up a few hours ago. And bills, man. Even setting them up is a pain. Anyways I only lost 5 hours of productivity this week so it’s not a big roadblock.
Development-wise my time is split between the first week when I worked on the Bird AI’s seeking and attack patterns when grounded and the two days this week when I thought I’d try out a different venue and casually revamp the character controller. More on that later.
The greatest part of a single player game is the mystery of unraveling it. This post goes into depth on the AI of the game and may spoil the experience for the casual reader.
Animation and Polish
First order of business last week was polishing up the swooping behaviors I’d just implemented and getting some other animation work done while I was in there. The birds now properly animate their swooping with a bit of a lift when going down and an attack animation at the trough of their velocity. I added an attack event using a new damage hitbox and some animation logic to get the damage working too, dealing a lot to the player if they’re slow enough to still be in the bird’s path when it comes. I plan on the attack knocking the player down too to really sell the impact, but I’d have to make some changes to the controller for that to work…
In any case, after that I fixed some of the navigation targeting when the bird was picking a spot to land and also animated a landing flight cycle to make it look like it’s trying to slow down. After that I got down to the brass tacks of planning the Seeking AI.
Hunting and Seeking AI
I figured pretty early that due to the narrow scope of the project, I’d like to guide the AI through the level design to give it a little more depth, which means using stuff like nodes and more expensive search patterns which would scale up poorly in larger environments (in no small part to the limits of my programming capability and the limits of the Unity Engine) but could be safely relied on and easily implemented with my budget.
Directly after landing, the Ave Apex entity will enter a Seek state where it will check the target LOS (line of sight) on small time increments while still watching out for new prey. If it doesn’t see anything for x amount of time, it’ll fly off.
Doing this required a bit of a huge refactor to the AI sensory system (which didn’t exist beforehand) so I massively changed the organization for the AI_Controller and the PreyInfo classes to adhere more to polymorphism so that I could write a generic AI_See and AI_Hear class to slap on anything and not have to worry about it.
Essentially for sight, the AI_See object will check LOS every x seconds on entities on the enemy layer within x meters and check if they meet the requirements for being detected (a simple function from the parent AI_AnimaInfo abstract class that splits into AI_PreyInfo and others depending on what I want the enemy to be). If it’s detected, it creates an AI_KnowledgePacket class which holds the information on it’s info object, information, and LOS connection and stores it in it’s ‘memory’ as one item. It takes care of itself, deleting after an editor-defined period of time without being seen. The new abstract AI_Controller functions ensures any child of the class will have this capability implemented.
I haven’t implemented AI_Hear yet because that’s dependent on some animations I need for the player which I can’t have without rewriting the character controller. Wait a second, this seems like a recurring theme…
So while seeking the AI will be watching out very perceptively, and be able to see ‘hidden’ entities when within a certain radius. When it does see something, the AI is very similar to the AI_Tribesman, and it targets the entity in navigation so that it moves forwards. When in the right radius, it simply attacks.
There are a few other knick-knacks like getting more impatient when it gains and then loses sight of it’s prey repeatedly, but I realized unfortunately that I can’t really do the full breadth of it’s combat AI without a generic IK solution which Unity doesn’t have. The bird needs to be able to reach under rocks, constantly look at the player by maneuvering it’s big old neck, target the attacks, etc and it can’t be done with Unity’s humanoid-exclusive inverse kinematics API. I’ve given some solid thought as to whether I should program this myself and save a considerable amount of money or just buy an asset and potentially allow much finer control in the future… but hey, I’m undecided. It’s a weird roadblock to encounter as a programming major – as I’m sure I could make a working version to some degree, but it’s time vs. money here and some of the assets, while expensive, offer a huge amount of features that could make things just a lot easier.
I think I’ll see if Final IK goes on sale sometime soon while I’m working on other stuff (it’s due for another sale about now…) and come back. I can finish up some other stuff with the birds for a while and just denominate that as a “needs polish” feature for now.
Physics-based Character Controller
So anyway everything has slowly been leading to this. I didn’t think a month ago I would want to rewrite this thing, but after playing the Team Ico games I grew attached to the taste of kinaesthetics and decided I wanted some sort of physicality to the movement. I’m rewriting it using a rigidbody and forces as the central mechanism for movement and gravity, so it’s not only for that delicious acceleration, but should make features like getting knocked over, sliding, and clambering properly doable instead of
not working at all being difficult to implement. I’m also particularly looking forwards to implementing first person animations and IK for the torso/legs. While it’s more work – animating and modeling a few pairs of legs with some easy unity-leg IK – people in forums always like legs in FPS games and it should add a lot to immersion and physicality.
While I’m more unfamiliar than I thought with how to make this type of movement controller, the only roadblock I’ve encountered so far is walking over tiny objects, which I’ll probably write about next blog when I’ve conquered or conceded to it.
These recent roadblocks and development priorities (and the extra lost time from moving in) have got me rethinking previous estimations on how time is gonna go.
I’m not gonna say it’ll take two weeks to finish the character controller, but it well might. Perhaps it’s deserving of it, and by the end I’ll have a better climbing system and the animations done, but I just don’t want to get stuck on a few things about it (like moving over small objects) that make me feel like I’m not using my time wisely.
With the birds on the backburner until that’s done, it’s not quite feasible to get a demo of them out by the end of summer, as the head IK is crucial for attacking the player in hiding places, which is like most of their purpose. I’d really like to buy the IK package on sale, but I’ll have to wait and see that out while I finish them up in other areas.
So what does this leave? I’ll try to finish the character controller (without animations if it’s a short endeavor, but the extra mile if it spills over to the second week) and work on stuff for the birds that doesn’t involve IK. Once my magic key to IK is bought, I’ll finish the birds best I can, implement it into the Tribesmen, then re-prioritize and plan what to do until Winter probably. Overall I’ll just try to build and maintain some momentum to get back into the swing of things.
Until next time, cheers.