Movement Part 1
Dashkin is all about platforming. Anyone who has ever played any platformer knows that movement is basically.. the entire game. This past week I’ve been exploring solutions on twitch to figure out how we’ll be doing this for dashkin.
Step 1 : Build Fatsack a test level
The first thing I did was create a simple level in Unreal 4 in order to test edge cases with collision. We made stairs, vertical walls, walls with tunnels, and a few giant ramps into space that we can run along and make sure our fatsack can into space. The idea being that if fatsack can traverse all the test objects properly in a horribly constructed danger zone, that he’ll be able to do so in a real level that we put together later.
Step 2 : Think a lot
Next I started drawing out all the cases I could think of and figuring out how we’d move our fatsack through the world. We went through an entire day of vector math drawings, hypothetical teleporting fatsack wormholes, and random tangents complaining about floating point to settle on our basic plan. We’ll be using sweep & overlap tests in unreal in order to move our object in an analog fashion (so not tile-based collision) through the world. Basically we sweep fatsack perpendicular to the normal of the surface he’s standing on, check for collisions, then resolve those collisions based on the situation.
Step 3 : Moving along the ground
In the simple case fatsack moves by nudging out of the ground by a tiny amount and sweeping forward in constant time along a vector perpendicular to the normal. If we run into an object we move to the point of impact and nudge out from that object by a small amount normal to the surface of impact. After we do this, we attempt to snap our fatsack to the ground. This allows us to run up and down slopes even if there are seams in the ground, as long as we don’t stub our toe into the ground.
Step 4 : Stubbing our Toe
The first issue with the motion is if we run into a piece of geometry which sticks out from the floor. A person in real life would just step a little higher and traverse over something like this (or they’d trip and fall on their face). In this game we want our characters to nicely glide over small seams in the geometry without any issue.
In order to do this we :
— Sweep in the direction of motion
— Move to the collision point with the sweep
— Raycast to discover a ‘mantle’ destination
— Sweep perpendicular to the impact normal
— Sweep along the perpendicular to the normal of the discovered mantling destination
Step 5 : Tunneling
One issue with mantle destination discovery is that we need to ensure that we can ‘step up’ into a hole that’s the same height of our character. In order to accomplish this we iterate in steps by our character’s height up the wall we’re climbing, move in the inverse of the impact normal, and again trace inverse in the perpendicular to the impact normal to discover the mantling point.
Conclusion Part 1 :
So far this method of movement has allowed fatsack to successfully navigate the ground in the test level!
Good Job Fatsack.