Day 3
Today’s, and probably tomorrow’s, work is reimplementing gravity. I actually had two “gravities”: first uses default Unity physics simulation, and it was used for player character only. Second one is a hardcoded gravity specifically for an enemy I added in the last day of the jam. I basically have two scripts that have almost identical code, plus a lot of hacky coupling with other components.
So I set to reimplement it and have one unified system, that is all clearly written in code and doesn’t use Unity physics simulation.
The idea behind my gravity implimentation is quite easy: find a collision point with a platform, get a normal in this point, use the tangent and the normal in this point as x and y axis.
For jumping I just fix normal vector until I collide with a platform. I also smooth “horizontal” movement in air, and to get horizontal velocity in local space I project character velocity on the tangent vector using dot product.