To develop my skills with manipulating positions and forces, I recreated the ascend, stasis and recall rune abilities from Zelda. Each ability is activated with a different key, and the others are disabled to only allow one active ability at a time. The image of each ability is also activated to show which ability is currently being used.
The ascend ability allows the player to travel upwards to the platform directly above them. To make this, I created a raycast above the player to check for eligible platforms. I then added a limit to the raycast so platforms would only be detected when they were close. When the raycast detects a platform, the player can click to ascend, which moves the player position to above the platform.
Stasis allows the player to freeze objects in place for a short time and build force to launch the object once unfrozen. I started by creating a setup to test the basic function of each part. The object’s rigidbody is set to kinematic when frozen so it doesn’t move. When the object was frozen, the player could press a key to build force, and the object would launch forwards.
I tried using a raycast from the player to find the object to stasis but this restricted which objects would be targeted as the player was required to face the object. I changed this to clicking on the target object so the player isn’t restricted with where they can target.
To build up momentum, I added a weapon object that enabled its collider when clicking, and increased the launch force each time the player clicked. However, this resulted in inconsistent attacks as it only worked when the player was facing directly at the object. I fixed this by adding a trigger area to the player and allowing the player to build force on the object when they were close to it. To set the launch direction, I calculated the direction from the player to the object each time the player clicked to build force and saved it. This direction is used when the object is launched.
I added an arrow indicator to show where the object would go. To make this I created an arrow prefab that is instantiated on the stasis object and destroyed when the object is launched. The arrow scales up with the launch multiplier to show it launches further, and rotated to face the launch direction.
When I made this I realised that the object would be directed towards the ground as the player is taller than the object, so I added an upwards force to the launch direction so the object wasn’t slowed by hitting the ground.
The recall ability rewinds an object for a set amount of time. To create this, I made a list that stores the position of the object over time, and overwrites the oldest items in the list after a set time to limit how far back the object can rewind. This resulted in jittery movement due to the physics trying to move the object at the same time. I fixed this by setting the object's rigidbody to kinematic when it reverses. I added object rotation to the list so rotation could also be reversed. Recall can be used on an object that has been launched with stasis, combining the abilities similarly to how they work in Zelda games.