When the Lever is interacted with I would like it to have an animation that shows that the lever has been pulled down, I have chosen to animate the Lever in Blender and then I will define the conditions for it to play in Unity. In this blog, I will also include a video of how the game works altogether and I will explain the setbacks I have come across at the end of the blog post.
I set the pivot point of the Lever's handle to be in the middle of the two cogs that the handle is attached to. This made it so that when I rotated the Handle down along the Y-axis the Lever's handle would stay equidistant to the cogs and will appear to move down with the cogs as it transitions to the pulled downstate. I keyframed the Handle at multiple points of it moving from top to bottom to have a nice smooth animation where all the keyframes are 5 frames apart, this will allow a constant speed as it moves down as well.
After I had animated this in Blender I re-exported the Lever model as an FBX to Unity and it automatically exports the animation with it. All I had left to do was to take the animation into the Animator window, if the animation a permanent downstate, and provide conditions in which the animation will be played.

The downstate makes it so that when the Lever is pressed and the animation of it being pulled plays there will be no further animations from the Lever, even if the Player attempts to interact with it again. I want the interaction to be a one-time occurrence so this aids me in helping make sure that it physically appears to only happen once. I originally had it so that the animation was linked to the 'Any State' but I found that when I pressed the lever the code would loop and the animation would also loop, this is why the animation is completely separate from any of the preset states given by the Animator.
In the end, I didn't need the conditions that I had made originally, I just needed to tell the Animator to play the 'Lever trigger' animation. I was trying to use conditions to make it work, but it turned out that they were the things causing the issues for me.

The lever will play the animation now when the Lever is interacted with.
This is the video showing the end product of my scene, I demonstrate how the scene is meant to be played through. My scene doesn't feel all that complicated, so I feel that maybe I should have been the first room that the Player enters but it's not too much of an issue now.
I wasn't able to make it so the player can leave the room unfortunately, I defined the reasons for that being the case in my 'Programing' blog. but you are able to do the puzzle for the most part. You're just trapped in the room. I am proud of what I have created especially with having to make a 2D game (Lasso Only) alongside my 3D room(The Elements) within 4 months. We had people leave the group and we've all had to do more than we needed to, I'm so happy that I had supportive willing teammates and I could not have made it the whole way without some of their help. In some ways I'm grateful that I was the last room, this is because due to not being able to leave the room it would be difficult to move the Player to the next room, so I'm happy I didn't burden my other two groupmates with that issue.
The whole playthrough of the game can be watched here, which was filmed by my group member Lucas. Thank you for reading my blog and joining me through the progress of making my room.
Comentarios