Coding and Game Development
Play Game
Finished Penny Pixel Level
Incorporates:
-
Custom Physics with Penny and the AutoMove crate
-
Camera follow with Cinemachine
-
Waypoints and moving platforms
-
Custom Tilemaps and rule tiles
-
Waterfall foreground and waterfall background with run in front (waterfall opaque), run in back (waterfall transparent)
-
3D sound for the waterfall, AudioListener removed from the camera and placed on our Player
-
Falloff and Respawn
-
Health pickups, Enemy, Gem, and Game Manager added
-
Enemy animated using sprite sheets and controlled via an Animator Controller
Moving Platforms
In this video, you can see the moving platform moving between two waypoints. It takes the character up to the higher layers of the level.
First, we get the direction to the next waypoint from the platform in order to draw the ray pointing where it is going. Then, we take the magnitude of this vector to see how far we are from the waypoint. We use this to check if we are close enough to the waypoint to move on to the next waypoint (code below). Then we move the position of the platform towards the waypoint by a max amount of distance that we could travel.
When the character or an enemy hits the platform collider, it makes its parent the platform so it will follow along. Then when we jump off and leave the collider, we remove the parenting so that we can move normally (code shown below).
(Parenting)
Physics
We created a custom physics implementation for our game's character controller and other objects. Our PhysicsObject script handles the logic for collisions, gravity, and momentum. Our character controller extends that script to get the functionality but adds player movement. The Crate has an auto-movement script which also extends the PhysicsObject script but just moves to the left. Both of these scripts use the code in the PhysicsObject script and just add extra logic on top of the physics logic.
Auto Move Script extending PhysicsObject