On this project, I implemented the main game mechanics, the Rollback. The rollback is a mechanics that allow the player to come back to a previous position while keeping their momentum and direction.
Let's explain how the mechanics work and how I have coded it :
1. First, the player will press the button X to create a clone at his position. We will store the player's position and rotation in an array.
2. While the clone is active, we will keep storing the position and the rotation of the avatar in the array, every X units traveled.
3. Activation rollback, we make the avatar invincible and use the position and rotation stores to make the avatar come back to his clone. When the player comes back to his clone, we set his direction and his speed.
But in order to make the mechanic more interesting, we had to specify some rules about orientation in the rollback. For example, when the direction is under the horizontal of the player, we re-adjust the direction to the horizontal to keep the experience fluid.