Snapback! *THE* Mechanic
Snapback! If you are going to name your entire game after a single mechanic, the implementation better work and, more importantly, feel phenomenal! Over the past week, I have been developing our title feature: the snapback. Here is what this feature does and where development is right now.
Overview
When looking at snapback, there are two essential modes: the teleport mode, which will allow you to teleport to a surface or over a ledge, and the snapback mode, which will enable you to snap back to where you were before you teleported.
To start interacting with the system, you must initially press a button to prepare to utilize this mechanic. By default, the keybind is set to 'Q' in this version, which will toggle teleportation preparedness on and off. Punching (using L-click) will also disable this state. When you are ready to confirm the action, you will press R-click.
Teleport Mode
In teleport mode, accessed by pressing 1, you will see a teleportation indicator that forecasts your teleportation mechanic. This indicator is dynamically updated as you move and look around the world, updating into three states.
Invalid
In the invalid state, a red X appears where you are looking. Attempting to teleport in this mode will result in nothing, but knowing what you are looking at is valuable information, even if you can't teleport there.
Ground
In the ground state, a green arrow will point to the ground where you are looking. Only teleportable ground surfaces will have this, and teleporting there will instantly snap you to the position indicated by the indicator.
Ledge
In the ledge state, a blue bent arrow will indicate the ledge to which you can teleport on top. Due to how physics works, you cannot see the top of a ledge, even if you know it's there. In order to still teleport onto the ledge, simply look at the side of it that you can see, and when you teleport, you will be placed safely onto the top of the ledge.
Snapback Mode
After you teleport, you can snap back to the location you were initially at before you teleported. While performing a snapback can be useful, it can also be dangerous. If there is a solid object between you and the snapback target, you can die, so you need to make sure you have a clear path before this action occurs. Right now, it is indicated with a simple capsule that turns red and green and only logs a message recording that you should have died, but the calculations are all in. We will be later replacing this with a more interesting visual model and will implement the death feature later on down the road.
Timer
The final aspect of this snapback mechanic is the timer. After you teleport, you will only have a certain amount of time before you are forcibly snapped back, even if it would lead to your death. Hence, you need to be careful to position yourself appropriately as the clock is counting down. Right now, this is displayed as a plain text box on the screen but will be implemented diegetically into the player model in the future. It is possible to teleport multiple times, chaining the snapbacks. After you teleport while a timer is already running, it will put your previous timer on pause and start a new timer. This means you will be snapped back multiple times in a row if you teleport several times at the last second.
Development
Progress
Implementing the teleport and snapback mechanics using a raycast to predict the location was effortless, moving a prediction game object to the raycast hit location. After moving the game object, it checks the collision layer to see whether it's a teleportable surface. If it is, it can determine if it's a ground or ledge surface based on the presence of a ledge offset component, which helps you guarantee safety when teleporting onto ledges. After determining the state, we can set the appropriate model.
I used a similar method to determine the snapback, line casting to the snapback location, which gets set after teleportation. If there is no collision, it is safe to teleport, or, if there is, call a death function (currently just a log statement).
To determine timers, we have a list of every teleportation instance that is added to every time the player teleports. For each update, we take the last item in that list and remove the delta time from its timer until the timer is at zero. At that point, we call the same snapback method as is called when the player manually snaps back and removes this instance from the list.
Challenges
One of the significant challenges I faced while developing this feature was some things that needed fixing with the teleporting when attached to the character controller. To accomplish teleporting, we update a player's transform, which the character controller doesn't appreciate occurring. After multiple different attempts to remedy this, we finally found a solution. If you disable the character controller before updating the transform, enable it after everything is happy, even though it all occurs within the same frame and is undetected by the player. Other than that, the implementation of this feature went very smoothly.
Future Plans
We currently have several enhancements to this feature planned. Soon, we will add a better snapback display model that is more visually appealing to the players. We also plan to allow for more precise control during the snapback to encourage more dangerous, complicated, and exciting snapback control. For the last few seconds before a snapback, time will slow and allow the player to try to navigate and maneuver to fit through tight gaps if they so choose. When this is added, we will also have a more extensive raycast system during snapback to determine if you die, take damage, or are safely snapping back.
Overall, our game's production is going well, and our core mechanics implementation provides a solid foundation to continue developing the game. It was essential to get this feature working as soon as possible, and I am proud to report the successful addition of this staple of gameplay to our game.
Get Snapback
Snapback
Speed-Runner Puzzle Platformer
Status | In development |
Authors | Shadowlight Gaming, Cats With Knives, theDoorProblem, Daniel Page, Seventyfive2, TheBudSkywalker, Tom |
Genre | Action, Platformer |
Tags | Dystopian, First-Person, Puzzle-Platformer, Robots, Singleplayer, Unity |
More posts
- Shaders Shaders EverywhereJul 24, 2023
- Game Balance is HardJul 18, 2023
- Snapback: Speed is the puzzle.Jul 10, 2023
- Saving Player DataJul 04, 2023
- My 3d Modeling Workflow for SnapBackJun 27, 2023
- The Art of CodingJun 26, 2023
- UIJun 20, 2023
- RotationsJun 13, 2023
- The Level Design of SnapbackJun 12, 2023
- Snapback Mechanic DesignJun 06, 2023
Leave a comment
Log in with itch.io to leave a comment.