At last, your wolf will be able to pick up food and carry it! In WolfQuest 3, you will be able to choose to dine out or bring home a delicious chunk of ungulate or a tasty hare (yes, yes, beavers are on the menu too). This has been one of the most common player requests, and it sounds simple, but of course implementing it is always trickier than it first appeared, as Tommi (our lead Unity developer) explains:
______Just picking up a chunk and putting it on the ground undoubtedly sounds trivial, yet it took me several hours to complete. And had this been a simple prototype project, it probably would have been much easier, but in a project as broad and complex as WolfQuest, every little thing is connected to many others, try as I might to keep everything as modular as possible.
1) We didn't know how exactly this was going to work when we started. Dave and I thought carefully about how exactly the chunks relate to the whole carcass – do they have their separate food value? How does that relate to the main carcass food value? Do you always get the same chunks? Etc. We also discussed how the player chooses to pick up a chunk rather than feed on the carcass itself, finally deciding to use a double-tap of the spacebar instead of a separate dialog popup.
2) The player and the chunk are not the only parties we need to consider. Some other animal may also try to eat the carcass or pick up a chunk at the same time, be that your mate or another player in multiplayer. Or two animals might try to pick up the same chunk (already separated and dropped) off the ground, or eat it. So I needed to write code to first “reserve” a chunk when you start the animation, even when the chunk is still on the ground. And we needed to figure out what happens if you're trying to take a chunk off a carcass, but then someone else eats the last food off that carcass, or also tries to pick the last chunk off... It gets complicated!
3) Other aspects of the gameplay are affected as well. The carcasses and chunks need to show in the targeting system (the one that displays the red and green wolf head), and having a chunk in your mouth affects what other things you can target and in which way (you can't very well bite an elk while biting into a chunk, now can you?). And how should having something in your mouth influence a wolf’s behaviors? (You shouldn’t howl with food in your mouth!)
4) Little details take a lot of time to sort out when there's enough of them. Like, how to make sure the chunk will be oriented correctly in the mouth, or lying neatly against the ground when dropped?
"5) Sometimes unexpected other parts of the code will cause trouble as well. I try to minimize this by writing clean, well-structured code, but I can't catch everything. For example, at first the animation and movement system didn't work quite right with these animations. That system is quite complicated, to accommodate different poses, animal momentum (to give them a sense of mass), pathfinding, obstacle avoidance, gait animations, utility AI, and flock-ing.
"We’ve now got it working pretty well, though there are still a few minor aesthetic issues, like posing the wolf’s head and mouth when carrying chunks."
Just be careful not to leave your portable picnic lying around, or another animal will find it first! That’s why wolves don’t cache their food in Yellowstone — too many competitors out there looking for a free lunch.