My focus for today was to solve a bug I found yesterday which involved Belly getting stuck underneath object when expanding (as show below). When Belly was stuck underneath an object it was unable to move unless the player reduced size so that they were smaller than the confined space. This bug needed to fixed as during the tutorial area of Portobelly, Belly has to manoeuvre through a cave area which has multiple confined areas and low ceilings. If the player was to run into this bug they would probably encounter it during the cave area.
My first attempt at trying to fix this issue was by sending a line trace out the top of the Belly which would prevent Belly from expanding if the line trace hit an object. When creating this solution I had to make sure that the line trace always stayed at the correct length even if the player changed size, this was achieved by multiplying Belly’s current size with the radius of capsule component and adding it to the Z axis of the end goal of line trace.
One of the problems with this solution is that if the player was not in contact with the ground but was in contact with an object above them they would not be able to expand. This can be solved by creating a line trace above and below the player which both return as hit to prevent the player from expanding.
During my time creating a solution to the player getting trapped underneath objects, I also wanted to test if the player gets stuck between objects left and right of the player. After some testing I found that this was also an issue although the player only become stuck when there was objects on both sides of the player. As the GIF on the right shows, the player is pushed away from the wall when there is only one wall next to the player. With this information I decided I had to create a solution similar to the first one but with two line traces coming from the left and right of the player checking if there are walls nearby.
This system worked although there was an issue with the player sinking into the floor when sphere traces detected a wall either side of the player. After some debugging I found that the cause of this problem was that the players capsule component would reset to its original size of 100 when the line trace would collide with the two walls. I decided to change the line traces to sphere traces because as they are more accurate and the trace can be set to a custom width/radius rather than being limited to a line.
Above shows all of the sphere traces working together. These traces are executed whenever the player uses the shrink and expand ability.
Now that the shrink and expand ability have been refined I plan to work on refining the general movement of Belly next week. For example finalise a jump height for Belly and finalise the dash ability as once I have completed these aspects of Belly I can begin to work on blocking out the level.
Rees, O (2019). Belly getting trapped on objects when expanding underneath them. [Offline]. [Accessed 20/01/2019].
Rees, O (2019). Using a line trace to check if there is an object above when Belly tries to change size. [Offline]. [Accessed 20/01/2019].
Rees, O (2019). Blueprint controlling the line trace above Belly’s body. [Offline]. [Accessed 20/01/2019].
Rees, O (2019). Belly trapped between two pillars when expanding. [Offline]. [Accessed 20/01/2019].
Rees, O (2019). Belly expanding next to one pillar. [Offline]. [Accessed 20/01/2019].
Rees, O (2019). My first attempt at trying to prevent Belly from getting stuck in horizontal walls. [Offline]. [Accessed 20/01/2019].
Rees, O (2019). Belly expanding between two pillars without sinking in the floor. [Offline]. [Accessed 20/01/2019].
Rees, O (2019). Both of the line traces working at the same time. [Offline]. [Accessed 20/01/2019].