Lost In Slime
Lost In Slime is a 3D platformer where you can climb any surface. You play as a slime that can jump, dash and ground slam to overcome the obstacles in the game.
I wrote everything located in this repo.
We used perforce for this project so the github commits are not an accurate representation of the commit history
An early prototype of the deformation system
Final version of the deformation system
The deformation system is based on a set of sphere collider nodes and a subdivided cube mesh consisting of only quads. The nodes are located at the cardinal axes of the slime mesh and send their position to the slime shader. The slime shader takes the position it gets and moves the vertices with normals facing the sent in position in the opposite direction.
The movement of the nodes is done using spring physics calculations. The nodes are connected to the root of the player and each other using springs. When one node moves it propagates the offset to the other nodes, resulting in a jiggly motion.
Traversal over round surfaces
Traversal over moving surfaces
Traversing different surfaces is achieved by moving along a custom navigation plane that we create based on the surface we are attached to. We take the normal of the surface and project our current forward velocity onto the surface to calculate the up, forward and right directions of the navplane. We trace every frame to see if we should attach to a new surface or lose our grip on the one we are currently attached to.
The tracing is done in four different directions (see the diagram to the right): our forward movement direction, the world down direction, the opposite of the surface normal direction and finally diagonally down backwards from the forward direction.
Using these directions we are able to account for most scenarios of geometry, the diagonal even allows us to traverse sharp corners. Additionally the player character gets attached to any surface it sticks to, allowing the character to travel with moving surfaces.
A diagram showing the tracing directions
Jumping and dashing example
Movement is done using a set of vectors to represent forces and directions, all these vectors are then applied in the same step meaning they cumulatively produce a resulting movement. An example is inputting movement and then jumping, the input movement is maintained and the jump force is applied on top of it. This sort of layered approach to movement forces resulted in a fairly easy way to manipulate movement.
Player input produces an acceleration in a direction dependent on the camera rotation relative to the character location and navigation surface. Moving in a direction is achieved through acceleration up to a max speed, stopping is done via a slight deceleration giving a satisfying feel to starting and stopping. The magnitude of the movement input vector is maintained when switching directions, resulting in snappy responsive movement.