top of page

Unity Development Part 10 (Surgery)

  • kw4u19
  • May 24, 2021
  • 3 min read

This development surgery, with James, took place during week 11.


My aims for this session:

  • Fix the bridge puzzle

  • Build cloud blowing puzzle

  • Make checkpoint system


The bridge puzzle


Below is a clip of how the bridge puzzle is working now. Upon using the boulder throw ability, the gap in the bridge does fill and the player is able to walk over it but he always gets stuck on the colliders that are on the bridge, no matter how many changes I make to them.


James and I tried fixing this puzzle by once again, using another form of collider. If it works as it is supposed to, the player should not get stuck on any part of the bridge at all. This was done by making a load of square sprites, with box colliders, and resizing them to make up a curve the same shape as the bridge steps. Then once that had been done, all the colliders could be switched off and the player should be able to walk over it. Here is an image of that process shown below.

We checked the scripts and the function of this bridge afterwards and it seemed to work fine so there shouldn't be any further problems with it.



Cloud blowing puzzle


Here are how the clouds look in the scene:

The expectation for this puzzle is that the players path ahead is concealed by some cloud coverage. They will use the gust ability to blow the clouds away from in front of the platforms, so they can see the platforms and pass on safely.


First, we added polygon colliders and rigid bodies to these clouds, as well as setting their gravity scale to 0. Next we create a new script on the player called "Cloud Blowing".


Here is that script:

Began with creating a list to refer to called "clouds" so the script will apply to any object with that tag.

The first method detects "clouds" in a radius around the player of 3f.

The second method moves clouds position on both the x and y axis, by applying a force to it.

The update method makes sure that the clouds only move when the player presses the "r" key.



Here is a test to show how it works:

As you can see in the video, the cloud movement is a little slow so I will definitely add a greater force in the script and decrease the mass or drag of the clouds in the inspector. Working in physics is really great for the reason that you can easily manipulate values to get different outcomes.


I also added a coroutine after this session as the clouds movement happened a little too quickly, before the gust ability animation had even started, let alone finished. So putting a delay on the movement has helped put those events in order. Gust animation and then cloud movement.



To summarise, the cloud blowing script detects clouds in a radius of 3f around the player, and if the player is to press "r", the clouds within that radius will have a force applied to them in a direction away from the player. In the script, I am able to change the values for force, magnitude and the drag, in order to experiment with how quickly or smoothly they move away.


I think this puzzle works really well, and I am happy with how it has turned out. It is also great that these clouds can be places anywhere in the level and same cloud blowing interaction will be able to take place, so I could use them as additional obstacles later in the level.



Checkpoint system


To make the checkpoint system, we began by making another square sprite, adding a box collider and then removing its sprite renderer. The box collider was set as a trigger and then resized so it was bigger than the player and placed anywhere on the islands where the player could walk through it.


Here is the script that is applied to the checkpoints and then the change that was made to the scene reset script:


CheckMark Script.





Reset Script.







The two scripts work together using public variables.

When the players collider enters the trigger box, the position of the player is transformed to where the collision happened with the checkpoint.



Reflection


I had a lot of fun during this development session and I am really happy with the outcomes. The game is really coming together at this point and i'm excited. I am going to keep looking into whether there's a better way to execute the boulder puzzle, because the problems with the colliders keep repeating themselves and it's quite frustrating.


Next steps


The next steps for me to complete in this unity development are firstly, the tree restoration puzzle and fix where there are still problems with the placement of the islands, shown above in the cloud blowing test video.




Kommentare


bottom of page