top of page

Prototype Assignment: Dashing and Level Implementation

A key component of any platformer is, of course, the platforms. Another member of the team designed and then built a basic level layout using Probuilder in Unity. This is a useful tool as it allows rapid creation of levels. A slight issue however, is that the level created features 3D meshes and colliders rather than 2D ones. Because of this, after importing the level, I discovered that the player character I had created would not collide properly with the platforms. I am unfamiliar with Probuilder so I installed it and explored some of its features to see if there was an easy way to resolve the issue. Unfortunately, I couldn't find one. So I decided to modify the player character and projectile prefabs I had created instead. Thankfully, despite being listed as such, nothing in Unity is ever truly 2D. Converting the prefabs to work in 3D was just a matter of swapping their 2D colliders and rigid bodies (physics managers) for 3D ones, and editing the references to them within the code. I did consider then swapping the sprites I had been using for 3D meshes but I decided against it for now, as good quality meshes and animations for them are harder to find and implement than sprites. With all these additions and changes, the game is now fully operating in 3D, but the various actors are represented by 2D sprites. This allows for 3D physics interactions, while maintaining a more traditional 2D platformer look.


Here's our current level:

Moving around our newly built level, I felt as though the player character could do with some more mobility. This could be done by simply increasing the movement speed and jump height, but that isn't especially interesting, and makes the movement feel quite floaty, something that is already a bit of an issue. Other options I considered were a double-jump and a sideways dash, but those didn't make the cut either. Instead, I decided to push myself to add a mechanic I hadn't built before before, a dash in the direction of the mouse. This kills two birds with one stone, as it can be used as an air-jump, a sideways dash, or something in-between. This also allows me to re-use the code I had written to fire the projectile towards the mouse position, something I had worked quite hard on. The dash works as follows:

  1. The character starts with their maximum of 3 dash charges ready.

  2. When the player right clicks while they have 1 or more dash charges then the dash function is triggered.

  3. The character's velocity is set to zero.

  4. The direction from the character to the mouse's location is calculated.

  5. The character is given velocity with a magnitude equal to the dash force, towards the mouse.

  6. If the character has 3 dash charges stored, this means the recharge function is not currently active, so the recharge dash function starts.

  7. A dash charge is expended.

  8. After a set time, a dash charge is restored.

  9. If the character is still missing any dash charges then the recharge starts again, restoring a charge after a delay.

Here are the dash and dash recharge functions:

In the process of putting together the dash mechanic, I decided that some changes should be made to the other movement mechanics to make them feel more kinetic. Here are a list of the changes I have made:

  • Sideways movement now gradually accelerates the character left or right up to a maximum velocity rather than instantly setting their velocity to the maximum.

  • The rate that the player can change the character's velocity is lower while the character is airborne, making the movement less floaty and forcing the player to commit to jumps.

  • Jumping now directly changes the character's Y axis velocity rather than adding force in the Y axis, this makes the jump velocity independent of the character's mass.

Here are the new run and jump functions:


Comments


bottom of page