How Osiris: New Dawn calculates monster crab scuttling
Osiris: New Dawn [official site] is a game I've dabbled in but not sunk a million hours into yet. The 'yet' is important because the game fits the bill of "Things I will potentially sink a million hours into". There's the screenshot potential of the ringed gas giants hanging over the horizon of desolate dusty wastelands alongside the type of crafting/exploration loops I sometimes get sucked into when there's a base I fancy building and a mecha crab to be ridden around like it's a robo-crustacean rodeo.
I'm dabbling right now rather than plunging in because I've burnt out on survival sandboxes and I wanted to wait for more story stuff to appear before getting involved with Osiris. HOWEVER, an interesting conversation about game crab foot maths with developer Fenix Fire's CEO and Creative Director, Brian McRae means I booted the game up and spent a lot of time watching my own feet and that of a monstrous killer crab.
The thing I was ostensibly there to talk about was some of the stuff that's arriving in Osiris: New Dawn as part of the new update. We started on a freezing planet in the Gliese 581 system and made our way towards lava oases and lava plants which create little Goldilocks zones of pleasant temperatures if you stay the right distance from them. Gliese 581 is also a real red dwarf residing in the constellation of Libra and McRae tells me that when the game launched "the scientists who actually discovered that reached out to us and have been sharing all their data and everything with us".
We head elsewhere – to a moon, I think – and land in more temperate climes. Well. I say "land" but what actually happens is I start asking questions about the skeleton of a giant worm, then McRae shows me an actual giant worm which is roaming about on that moon and somewhere between the questions and the worm harassment we crash into a tree and get stuck. "They should revoke my pilot license," says McRae with a smile as he wrestles the spacecraft free.
He explains (as we land properly) that Fenix Fire are also working on more weather events for the game. "We're working on this twister tornado which is really cool, so you can see this big funnel coming and we're going to make it horrifying."
The last matter we discuss before getting derailed by crabs and their feet is addressing the new player experience. McRae tells me that the team will be adding an opening cinematic with interactive sections where you follow the journey from Earth to your subsequent crash site. Apparently there's a malfunction relating to your light speed travel system and you'll end up taking an escape pod for a crash land on this far-flung planet. There might be a way to land safely if you handle the interactions well, which is a nice touch and makes me think of Chris Pine struggling with the Kobayashi Maru training exercise and finding a way to win (through cheating, admittedly because the point is that that one is a no-win scenario but SHUT UP because they never finished the official hearing in that movie).
You're in search of the original Osiris One mission with whom you have lost contact and Fenix Fire are in the process of building that story side of things out with more missions and things to do or discover.
So I've played enough of Osiris to know that you'll be minding your own business, looking at a tree, and then a crab will come and try to cave your skull in. It's not a proper crab in the sense of earth taxonomy because it has four legs, but it has a carapace and a set of angular legs that have a very crab-ish/lobster-y aesthetic.
The joints also work a bit differently to the crustaceans I'm most familiar with as the legs form a kind of "M" shape so the merus (which is the thigh bit) goes upwards, then there's a joint which is attached to the downward-pointing carpus, then another joint and the propodus which scoops upward again, then a last joint and a MAHOOSIVE dactyl. The dactyl is the crab terminology which I'm adapting to use for the monster's foot which will use to stomp on your head and kill you. In fact, all of this biological terminology is being repurposed from earth crabs just so I have a point of reference.
Working out where to actually put any of these dactyls at a given moment is where maths comes in. Fenix Fire are using inverse kinematics to try and solve the problem. Loosely and simply, inverse kinematics is the process by which you figure out what your robot or character or whatever's limbs need to do in order for part of the body to be in a desired place. Say you want your crab monster to shuffle forwards or reach for a cup of coffee, Inverse Kinematics is about taking the desired end point for the dactyl and working out how to get there using the right bits of the crab monster.
There's a really interesting Intel blog about Inverse Kinematics as well as some basic info about why you might prefer it to a system called Forward Kinematics.
"There's no baked animation on this thing at all," says McRae of his crab monster. "It's all handled through maths. We figure out where the body is and then when we move forward the legs kind of figure out where they want to step. All the math is calculated on the fly."
The calculations require information about the terrain so that the crab monster can believably traverse the environment. That's where a technique called ray casting comes in. What this boils down to is that the computer determines the first object a ray will hit when travelling in a line (the ray is thus cast and used to figure out intersections with object geometry, hence the name). "Imagine the radar scope of an assault rifle but we're doing that invisibly at runtime to come up with a point in 3D space," says McRae.
That point can then be used as the ground upon which the tip of the crab monster's dactyl will land. "We know where that is. We know that this point right here [he indicates a dactyl onscreen] wants to go over there. This leg is made up of all these different parts and there's a solver that figures out how to stretch and recoil the limb."
Given the crab monster has four limbs to keep track of, there's also a part of the system which tracks the limbs currently in motion. For walking, if the front right leg is striding forwards, the back left is also allowed to move but the other two can't. "It winds up creating a spider-like movement and it's all happening in math."
I ask whether the team did a lot of research on how real crustaceans, arachnids and other arthropods move.
"We completely geeked out on it, to the point where if [the crab monster's] walking you see the opposition legs moving but when he's running it's the front legs then the rear legs. We studied nature a lot."
This is more apparent in the crab mecha which players can construct themselves out of bits of crab monster and some circuitry components. The crab monsters kill me too quickly for me to appreciate their gait, but when McRae is romping about atop a crab mecha you see the difference between walking and running. The former uses that alternating opposite leg approach while running switches to the front and back legs operating in pairs, pushing and pulling in a kind of crabby gallop.
Here's a gif I made from a YouTube video to illustrate the point:
The player character is also animated using this system – no baked animations – so you end up with a sort of sidle if you go up a hill with a weapon in hand, or you jump off a ridge and your legs stop moving until you land. There's a little leeway in that there are some transitions between limb positioning that are smoother than others, but watching my little astronaut running about was a really satisfying experience.
My last question on the crab matter is whether a true decapod is on the horizon or whether the system simply can't handle that many legs.
"We would love to have centipedes and things like that," says McRae."It would be so amazing. It's a matter of the cost to calculate all those limbs and we have to be thinking about multiplayer.
"The way we handle all of that right now is a pretty intelligent approach to multiplayer. Usually a server handles all the creature movement and distributes that out to players. In a lot of MMO players these creatures will slide around the world. I used to run a cinematics studio for a number of years and I know how important it is to have grounded feet to create a level of believability.
"What we do is when we have a creature your computer is driving all of the feet of that creature because you're interacting with it. The computer is controlling it and you as a player are fighting that thing and your computer is sending that data out to everyone else in multiplayer. So if they're doing something else and they look over it looks perfect to them and it'll be even more perfect to you because you're the one that's interfacing with it, if that makes sense. It's kind of a high-level idea."
And thus I'm concluding that the cost of calculating a centipede's sashay is perhaps too high for now, but I've added "Osiris: New Dawn centipede" to my Google alerts just in case the future brings me a multi-legged gift.
BONUS CRAB FACT: Today I learned that the claws of a crab are formed from the dactyl and the propodus. The propodus is the penultimate segment of the leg but in chelipeds (the claw-bearing legs) the propodus grows to form that big, beefy, stiff bit of the claw – it's like a weaponised sleeve – and the dactyl is the mobile bit the crab can use to make the claw grasp. So the propodus is kind of an armoured sleeve with a built in motionless chopstick and the dactyl is the chopstick you move in order to pick things up or crush them or hold pencils to write notes in your crab journal.