Tuesday, March 21, 2017

Unity Tutorial: Making a Fire Puzzle



One of the very first thing the tutorial required me to do was to add flames to the torch. Thankfully, this wasn't hard to do, seeing as Unity's particle system (or at least the variables surrounding it) are similar to Unreal's.

I clicked and dragged Unity's fire asset to the torch and aligned it with the tip. There is one thing that bothered me that the instructor did, which was to disable the sparks flying off the torch. I feel like this was a mistake, because sparks are, in my opinion, amazing and add to the torch.

I kept the sparks in, but lowered their size and the amount of particles that spawned
And I'd say that it made the torch look ten times better!


After this the instructor began coding a script to have the player pickup and drop the torch. Unfortunately, I began running into trouble with the coding...

I was copying down the script verbatim based on what the instructor showed
and yet I kept getting these errors that caused the scripts I wrote to not work. One of the more common was that "GameObject" was an incorrect line of code. Apparently the latest version of Unity's C# code stopped using that in v.5
I tried to Google various fixes for this problem (including importing a Data file from the base Unity files into my project), but none worked. Apparently the instructor's C# coding was outdated. It was beyond frustrating trying to get the scripts to work, so in the end, I imported the ones from the tutorial files.

For some reason they work, and I don't know why.
also the orientation of the torch was wrong. I fixed that by rotating the node that the torch attached itself to

So I'm far from being a coder (but I think I could at least tell you what a line of code can do).

by using the instructor's script, I can hold the torch
Also, funnily enough, for a time when I dropped the torch it would fall through the floor, despite having colliders.

I have no clue what caused this (the environment had colliders too), but for whatever reason it eventually stopped. I thought it was a funny bug, at the very least.

I tried to go for a second round with the coding, this time to make it light on fire.


It didn't work (again). I had to import the instructor's script to make it work, unfortunately.

After the torch would successfully be lit by the bonfire, I was to make an animation (and script) for the lever(?) that would carry the torch up to illuminate the answers to the puzzles.

Animation was easy to do. Just make two keyframes that have it go up. The instructor suggested to flatten the curves of the animation for better transitions.

This is what greeted me in the curve view.

And yet somehow I made it transition the way he wanted. It was shot in the dark right clicking and hitting "flatten" in where I figured the nodes were.

Still, the torch went up (also had to import the script for that).

For a time the animation kept looping, forever sending the torch up and down in an endless purgatory of motion. The fix was a lot easier than I thought, though: go to the animation file and uncheck "looping".

After that came scripting the puzzle logic (which I had to import yet again), a well as animating the platforms and the door.

and the door finally opens

No comments:

Post a Comment