Tuesday, March 21, 2017

Unity Tutorial: Space Station




The first step to creating this level involved prefabs. 
I created prefabs for each section beforehand
Since the models were already provided to me, I used the vertex snap feature (CTRL + V) to put them together, and then grouped the models. After that, I created an empty prefab and dragged the group there.

The long process of putting together a basic level began. In the end, after vertex snapping all the duplicated pieces together, this is what I had:


A simple level loop. After that came applying the materials and textures, which was pretty simple since it was mostly me clicking on one prefab, going to its materials, and assigning a diffuse and normal texture to it, then hitting apply.


During this time I also added in the inner walls, as well as interior rooms using the basic floor and wall meshes (which I also turned into prefabs beforehand).

The instructor needed a starter area with cryopods, thus I made one.


This was followed by me adding in the fire particle effects, which I had to import from the tutorial files as this new version of Unity no longer has them.

the old version of the fire, reborn in Unity 5!


I then lit up the rooms and halls with some lighting. I thought I might add some variety, so the starting area was made a menacing red, while the hallways were given a chilling blue.

Note how the lights by the doors are slightly brighter than the others
Since Javascript was being used, the scripting actually seemed to work!


Once the scripts were in place I began finalizing the level.

a dead end was created to add to the sense of  chaos, along with multiple props all over the level. I animated the door to open and close on a loop, to signify that it is entirely broken
the final room, where the player escapes into their own reality. I call it the "crate room"
the room that is engulfed in flames (not shown: the flames). I call this room "barrel hell".
As a final requirement, I was supposed to create a transition to another level. Thus, I had to quickly create a second level...

the player spawns on the platform in front of my imported model, all while a chorus sings "hallelujah" in the background
I have no name for this level. Maybe the ship is off to take them to space valhalla.


After all this was done, I began building the level as an exe.

Which takes forever.


Near the end I did face some problems that I could not figure out the solutions to. Namely, they were:

  • the GUI not appearing
  • the player unable to look up or down

The first turned out to be an easy fix in that the script's coordinates were not aligned with my monitor.

The second one, though, I still cannot figure out, even after looking online for answers...


Overall though, it reflects my biggest problem with Unity: which is the coding. I am by no means a coder, which makes the program and it's reliance on coding that much harder for me. I do like some features of Unity, such as the vertex snapping, materials, and the prefab system, but the coding aspect really detracts from it all.

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

Unity Tutorial: Desert Puzzle


the map from the top
In addition, here are two things I missed during the video:


The AI pathfinding map. I tried my best to cover the gaps, but there were a lot more holes than I anticipated. Baking the pathfinding map was much faster than I anticipated, so I was able to revise the map a lot more without having to worry too much.

The complicated animation set for the character, where the variable "isrunning" decides whether the character plays the running animation or not.

The animation transitions are set up so that they don't loop over each other (has exit time). The script plays with the variable in order to get the whole thing to work.