Unity Development Part 8
- kw4u19
- May 24, 2021
- 6 min read
Updated: May 25, 2021
This development session took place during week 10.
My aims for this session:
Analysis of boulder-bridge puzzle - what is wrong?
General clean up of slice, check tags and colliders etc.
Get Molly's Eagle animations in
Get Molly's ability movement animations in and functioning
Import Emilia's Butterfly animation and write the script for its movement
The boulder-bridge puzzle
The video below is how the bridge puzzle looks as of now. I have made no knowing changes to this since it was created in a development session with James, other than trying to redraw the edge colliders because the polygon collider definitely was not working.
As you can see in the video above, the player has to jump up onto the bridge to get onto it. The Shaman is supposed to fall through the gap in the bridge but instead he walks right over it. There is no collider in the way that I can see so I am confused as to why this is happening. Furthermore, the player gets stuck on the ends of each collider so gets trapped in on the ends of the bridge and the ends of the bridge gap.
I removed all of the assets and replaced them all, and remade the colliders, hoping that the same problem wouldn't occur with the gap and it did not, so there is nothing wrong with the script but instead how its been put together in the scene. The gap is now there but the player still gets stuck on the edge of colliders and in the middle of the bridge once the gap is filled.
I am also not really happy with how this puzzle functions and would prefer if the player were able to spawn and throw the boulder as a new game object that would then land into the bridge gap and could be walked over. I am going to speak to a friend who should be able to tell me how to accomplish this and also work out how to adapt the player so they do not get stuck on little ledges.
General clean-up
I went through the full build and made sure there were colliders on all of the platforms that were sized correctly and the players y position on the islands was consistent. I also walked the player through the build a few times to make sure they were placed where the player was able to jump onto them without issues but still somewhat challenging.
Animations
During this session I also set up the animator for the two eagle sprites. First the eagle that will be patrolling the sky and second, the eagle that will be blocking the player path before taking off and leaving the scene.
Eagle 1 - patrolling eagle. Simple enough; just added the patrol animation to the eagle and made sure it loops. Later, I will add a script to this to make it fly between two points in the sky.

Eagle 2 - There are 3 animations: Idle and take-off which then transitions into the same animation used for the patrol above. Below is an image of the eagle in the scene in its idle state, blocking the path ahead from the player

And here is the animator controller for Eagle 2, below. This is set up so of course the idle state is the default state. Then there is a transition from Idle to Take-off which has a trigger parameter called "isTakingOff". When this trigger is switched on inside the script, the animation will change from idle to take-off. Then there is another transition from take-off to Fly which has no parameters so will just play straight afterwards. The Idle and Fly animations have loop checked whereas the take-off does not require that.

I will be setting up the scripts for this eagle when I set up the rest of the panpipe puzzle.
Ability Animations
The ability animations occur on the event of a button press, when the player us using the abilities. The boulder throw is activated by pressing the "e" key and the gust ability is activated by pressing the "r" key. The animations that I am implementing in this session are the motions that the Shaman makes when using these abilities, so are added to the player animator.

The abilities can only be used while the player is stood still, idle. Therefore the animations for them only have transitions to and from the idle state. If the player were able to use the abilities while running or jumping, I think this would get a lot more complicated. For example what if the player jumps, then uses the ability and then stops moving, going back to idle. Wouldn't I then have transitions all about? I think so, so that's why I have made it so they can only be used when idle.
As the abilities only happen on the event of a button press, the parameters are triggers. So the boulder throw happens under the condition that the trigger for isThrowing is activated, and then after the animation has played, it transitions back to idle. Therefore loop and exit time are unchecked. The same goes for the gust ability animation but with the trigger names "isBlowing".
Here is how this is written into the script:

This is written into the player movement script, under update. Upon the allocated key being pressed, the trigger for the animations is set. In the start method I have told the script to take the animator from the player for these functions, the same way it does for the other movement animations.
This video clip below shows how the ability animations look in the game. The boulder throw is an upward movement from the ground, as though the boulder is being pulled from the earth and thrown. In gust animation, the Shaman swirls the staff in tight circles and shakes as though the force of the gust he is creating is throwing him off balance.
The next steps for these ability animations, is adding the additional animations of the boulder moving through the air and the gust of wind that is being created from using the staff.
I think that the animations are quite smooth and they transition to and from the idle animation well. It is clear which ability is in motion thanks to the characters movement and the colour indicator on the staff. I think I might face some issues later on when it comes to getting the timing right for the two animations that will take place for either ability use.
The butterfly movement
The butterfly was created and animated by Emilia and I sourced this script online because I could not work out a way to get it to move the way I wanted it to, by myself. I then made changes to the sourced script to adapt it because it didn't have the exact outcome I was looking for.
Here is the script I found online: https://handyopinion.com/game-object-zigzag-movement-from-top-to-bottom-in-unity/ The programmer has explained what each step of the method does in understandable terms which were really helpful for me.
In this script the creator has written instructions for an object to move in a zigzag pattern vertically from the top to the bottom of the screen. For the butterfly in our vertical slice, it needs to fly across the screen horizontally as if it is following the player or guiding it.
Here is the script adapted and then attached to the butterfly:

The only changes I made to the script I found, was to change the transform of the axis in the start method, from "right" to "up. And then changed vector3 direction from "right" to "up". This has basically just rotated the direction of movement for the butterfly.
I turned frequency all the way down to two in order to make the shape the sine curve a bit longer on the vertical axis and shorter on the horizontal. I then changed the speed up a bit to a more reasonable pace, just a little slower than the player so it doesn't move past them and is lost from the scene.
I think it would be great to later make a trail of them or perhaps have a few butterflies just resting on parts of the scene and fluttering their wings.
Reflection
The unity sessions this week were very productive and I feel as though I am learning so much as I go. In the moment of doing it, it's always quite confusing and I do struggle to keep up with the language. But then when it comes to documenting the process, it all starts clicking together in my head and I am finding that really rewarding.
For the next part of development, I have realised I am missing the lantern png's for when they are ignited so I need to ask for those so when I start creating the puzzles next week I can also get the lantern sprite-switching set up.
Comments