top of page

Unity Development Part 6

  • kw4u19
  • May 24, 2021
  • 3 min read

Updated: May 24, 2021

This development session took place in week 9.


My aims for this session:

  • Add script for turning left and right

  • Re-slice the platform sprite sheet because I cut pieces off last time

  • Build the bridge puzzle and set it up to be made functional


Script addition for flipping the player when turning


This was a very simple piece of script that I definitely over-thought but understood quickly once I worked out the functions.





I first set up a public bool, on the player movement script, shown above, and then in the inspector for the player made sure the option for facingRight was checked in the box. Then in the update method inside the script, wrote these two if statements for when the player is moving in a negative direction on the horizontal axis and facing right, and when the player is moving positively along the horizontal axis but NOT facing right (thats what the exclamation point is for). In these two instances, the player sprite is then told carry out the Flip method!

Here is the piece of script for the Flip method!





Flip when facingRright is not true and therefore Rotate the player 180 by 180 degrees, displaced in the 3D space.



The bridge


I have taken the bridge assets that I have and put them into unity in a little mock-up of the scene with the finished, blossom and lantern assets included too. The bridge was made by Emilia and is split into three separate png's so I have been able to the pieces on separate layers, with the steps on the same layer as the player.


How the puzzle is expected to work:

The player should at first be able to walk up onto the bridge seamlessly and then when they get to the gap, they should fall straight through it and descend to their death. Then they can try again, and using the boulder throw ability, they should throw the boulder into the gap in the steps where it will get lodged and then the player will be able to walk over the bridge just fine.

Now, here is where I had some problems. No matter which type of collider I used on the bridge, the player wasn't able to walk over it smoothly at all.

First I used a polygon collider which took the shape of the bridge and left out the gap in the middle. However, it also left gaps where space has been left for the posts of the bridge to sit. As in Emilias design, the steps are the front layer and they almost slide into place on top of the other layers. This collider was problematic therefore, because the player would not be able to walk over the parts where there are gaps in the steps and would have to jump over them instead. But if the player could just jump over them, what is to stop them from jumping over the bridge gap and making the puzzle completely reductive.


In my player movement script, it is set up so the player can only jump from a position where they are standing on an object that is tagged as "Ground". I have not tagged the bridge steps as "Ground" so the player will never be able to jump while on the bridge and defeat the point of having this puzzle in the game.


Here I have tried using an alternative collider called an edge collider. There are actually two of them either side of the bridge gap. And they follow all way down to where the box collider are on the islands in an attempt to prevent the player getting stuck from moving on and off of the bridge. This attempt, sadly did not work at all and the player is still getting stuck, not being able to move onto the bridge unless they jump onto it. But they do fall down where the gap is.


I am not too sure how to solve this and make it functional so I will book a development surgery session with James later this week for some guidance and advice. This development session was still successful because I learnt more about the features of unity and did achieve the objectives I set myself for this session.


I also put in the new idle animation that Molly created but there were some issues with it. The perspective of the player was front on rather than a side view and it was completely out of scale to the other animations, the biggest problem being that the head shrunk to less than half the size. So I have asked her to create a new idle animation that fixes those issues.








Comments


bottom of page