Character and Control Overview
The player character in this game uses custom physics and is built to use touch input. There are two resources: speed (souls collected) and dash charges.
Movement
First of all in this endless runner, the player actually moves right. It's a common practice to keep the player stationary and move the level instead. This avoids a problem called float overflow which happens when you try to exceed the maximum value of a float in memory. By moving the player right, float overflow is a risk for endless runners, because some players can actually play them endlessly. The reason I decided to move the player was because this allowed me to use actual physics calculations to handle slopes and collisions. Later in development, this turned out to not be needed and the complex physics were scrapped for more customized, simplified, and specialized physics. Ultimately, I calculated how long it would take the player to reach float overflow, and the player would have to play for several times longer than the earth has existed. I consider that a non-issue.


This is the basic Movement function with collision. This game uses "cloud" platforms that you can jump through the bottom to get on top of. The collision is done by casting a circle along the velocity vector for the frame and moving the hit distance along the y. Collision only effects the Y velocity, and turns off gravity when a platform is hit. Since there are no slopes or walls to collide with, only collision effects the ground. Because of this, I am able to optimize the ground check to be handled when a collision is registered rather than making a separate check for it.
After movement is completed, if the player is grounded, a single point overlap check is done at the player's feet to see if the ground is still there.

This acceleration function is used to calculate a velocity to be passed into the above move function. This function uses a target x speed to decide whether to speed up or slow down. This allows me to manually set the target speed manually for certain speed changes. In this game, the number of souls you have collected also slows you down. The target speed value is obtained by evaluating the number of souls collected on a Unity AnimCurve.
Controls
The controls in this game are designed to work on mobile devices, and A few different control schemes were considered. First, we tried swipe controls. In this scheme swiping up would trigger a jump, and swiping right would trigger a dash. We quickly realized that swiping up didn't feel responsive, so we changed the binding for jump to a tap. I attempted to build a scheme that would allow for a tap for jump and a swipe for dash, but realized that there is a technical limitation to combining swipe and tap actions. In order for both actions to exist, I would have to delay input on the tap to see if the player would move their finger for a swipe. Even after trying a complex system full of checks and ifs, using that control scheme introduced input lag into the tap, and unreliability to the swipe.

We finally settled on a control scheme inspired by popular endless runner "Robot Unicorn Attack." In this control scheme, tapping on the left triggers a jump, and tapping on the right triggers a dash. These controls proved to be much more responsive and allowed for much simpler code to achieve.