Ori and the Blind Forest: Building in Unity

April 27, 2019

Mimicing Ori in Unity

Bash Action

Youtube – Ori and the Blind Forest – Game Design Reel

By: James Benson

Youtube – Making Ori Y Bash [Unity C#] (Ori and the Blind Forest) #1

By: Wabble – Unity Tutorials

As a big Ori and the Blind Forest fan, I just wanted to see if I could find some tutorials to put together some of the movement or actions given to the player in Ori. The first video is a cool sample of a lot of the different game mechanics seen in Ori, as both their simple concept version as well as their in game version. This is actually extra helpful as the concept version really simplifies it down to what is really happening and makes it easier to process and disect to replicate.

Houdini Vex

April 23, 2019

Houdini Vex Code

cgWiki – HoudiniVex

As I was working on a chandelier project in Houdini, I needed a lot of help learning the ropes of Vex. In my research I came across this huge resource that was not quite useful at the time, but looked like a really good place to start for some vex tutorials. I want to come back later to this resource to help get a hang of the basics of vex in Houdini.

Intro to Python Programming with Mosh – Pt. 04

April 22, 2019

Intro to Python Programming

Tutorial – 04

Youtube – Learn Python 3 for Machine Learning & Web Development [2019]

By: Programming with Mosh
Progress

End Time: 1:41:55

Next Part of Tutorial: For Loops

NOTES

Weight Converter

This was a simple exercise to try and create a simple weight converter. It would take a user input weight and ask if it was in Kilograms or Pounds (lbs), then convert it to the other unit.

Their solution to this exercise provided a nice way to make strings less case sensitive. Since the unit input was just the first letter of the unit abbreviation (L for pounds and K for kilograms), this could make it completely non-case sensitive. You simply use the upper() method on the string you are comparing a value for before checking what it is. Then you only have to compare it to the capital case instance and either they will have already typed in the capital instance, or you will have converted the lower case to an upper case before comparing.

While Loops

These are used to execute blocks of code multiple times. The syntax for while loops is similar to C#. You just use the while key word with a condition, ending with a colon. Then the following indented code will be executed as long as the condition is met.

Guessing Game

This uses a while loop to build a simple guessing game.

This example went over “refactoring”, which is renaming a variable and all the instances of it in your code. This can be done with the keyboard shortcut: Shift + F6.

The Break command is used to immediately exit the program out of a while loop. This is useful when a varied condition is met that doesn’t need the loop to run again. This also prevents any Else counterparts of the while loop from executing.

While loops can also have Else counterparts. These will execute if the entire while loop is completed without the use of a Break.

Car Game

This was another exercise to do on your own. This time it was creating a “Car Game” that just said you started the car if you typed ‘start’ and stopped the car if you typed ‘stop’. I used a simple while loop to contain the game as a whole, with a game_started bool. The entire game ran in this while loop while game_started is true, and terminates when that is set to false. This gave me a way to quit the game when the user typed in quit.

Within the main game while loop, there were just a lot of if statements (with elif) to determine what to print based on what the player typed in. There was also an extra bool added which was car_started, which could be used to determine if the car was already started or stopped. This could be used to make sure the player couldn’t stop an already stopped car or start an already started one.

Houdini Flower Tutorials

April 13, 2019

Houdini Flowers

Tutorials

Youtbe – CGI Rose using Houdini and Redshift by Stephen Bester | VFX

By: CG Record

Youtube – Houdini Tutorial: Creating Water flowers blossoming | Project File for download

By: CG Record

Vimeo – Water flowers blossoming in Houdini. Tutorial + project (HIP,comp,ae)

By: Mike Stoliarov
UPDATE 4/29: This is the same video as the one above, but has higher resolution options so you can see the steps much clearer.

These are a couple tutorials showing how to create flower-like objects in Houdini. I’d like to get into making plants with Houdini at some point, especially flowering plants, so I just wanted to start gathering some resources for that.

While one of these tutorials is for creating water flowers, a lot can be taken from that for the core of the flower making process. The other tutorial is for making a rose, which is perfect for a lot of flower uses. It also says it uses Redshift, which I’m not sure what that is or how much of a difference that makes in Houdini’s workflow for any reason.

Intro to Python Programming with Mosh – Pt. 03

April 7, 2019

Intro to Python Programming

Tutorial – 03

Youtube – Learn Python 3 for Machine Learning & Web Development [2019]

By: Programming with Mosh
Progress

End Time: 1:16:25

Next Part of Tutorial: Project: Weight Converter

NOTES

Arithmetic Operations

In Python we have the same operations used in math, as well as a few extra ones. There is addition, subtraction, multiplication, and division.

Here are a few of the extra operators. By using //, it returns the integer of the division with no remainder. Using the modulus, %, it returns the remainder after performing the division. Finally, ** is exponent, so this will raise a number to the other values power.

Then there is the augmented assignment operator. This is done by placing the operator directly before the equal sign. For example:

x += 3
is the same as: x = x + 3

Operator Precedence

This is the math concept where certain operations are performed before other operations. Many of these in Python are the same as those in basic math.

Math Functions

This just covers so more basic math functions: round, abs

Round rounds your value to the nearest integer. Abs returns the absolute value of a number.

If you want to do very intense mathematical calculations, you will want to grab a math module to add to Python. This module would give you more built in functions to perform mathematical functions. This is done by typing:

import math

at the top of your Python code. You can then call functions from it in your code with math.FUNCTIONNAME.

if Statements

The syntax of if statements is a bit different from C#. The syntax is as follows:

if STATEMENT:
functionsToPerform()

A colon is used to end the if conditional, and the functions following it are determined just by the indentation. To end the statement, you just remove the indent.

To perform else if, you simply type elif in Python. Else remains the same as you type the full word.

Logical Operators

These are the AND, OR, and NOT operators. In Python, logical AND, OR, and NOT are done by simply typing the word “and”, “or”, or “not” in the place they are needed. They do not use symbols.

Comparison Operators

These are used to compare variables with values. These are operators such as greater than and less than. These are all the same as C#, including the equivalency operator that is ==. Not equal is also the same, which is !=.

Houdini Basics

March 29, 2019

Houdini Basics

Interface and Physics

Youtube – SideFX Houdini For Absolute Beginners
Youtube – PHYSICS For Absolute Beginners – SideFX Houdini Tutorial

By: Surfaced Studio

As I am on vacation over break, I just wanted to quickly check out some basic Houdini tutorials to go over for my classes next quarter. These ones seemed to cover the absolutely basics as well as getting into some of the simulation aspects I want to check out specifically using Houdini.

Callbacks and Event Systems

March 18, 2019

Creating an Event System in Unity

Event System with Callbacks Tutorial

Youtube – Unity Tutorial: Callbacks and a (Really Awesome!) Event System

By: quill18creates

Following in my learning of delegates and events, I stumbled across an interesting tutorial on creating Event Systems in Unity. I just wanted to note this as something to follow up on in the future since the general concepts I got from skimming through sounded very promising and good to learn about.

Unity Programming – Delegates and Events

March 18, 2019

Unity Programming – Delegates and Events

Tutorials and Definitions

Youtube – Delegates – Unity Official Tutorials

By: Unity

Youtube – Events – Unity Official Tutorials

By: Unity

The scene management update has made significant progress, I am now currently loading and unloading the proper scenes at the proper times. The timing of the loading and unloading is still off however, as well as the fading animation timing is very strange. The fading error makes sense since I have the scene transition and the fading in the same method currently, so I will look to separate those and time them properly with IEnumerators. I was also told today that OnSceneLoad delegates would be a very helpful feature for me to look into to fix all my scene loading timings.

The basic IEnumerator timing I was also suggested to look into was: wait until animation is done, wait until next scene is loaded, then unload scenes to be unloaded.

Upon investigating delegates, I found that they are a very big part of coding in general. Looking into delegates also led me to events, which are somewhat like a specialized type of delegate. I believe understanding both of these will be very beneficial to my current scene loading issues, as well as being very useful for many other game programming purposes, so I wanted to take the time to better understand them before rushing back to my scene development needs.

TERMINOLOGY

Delegates

Delegates: Simply a container for a function that can be passed around, or used as a variable. Just like variables, delegates can have values assigned to them and can be changed at runtime. The difference is that while variables contain data, delegates contain functions.

First you create a delegate template with the delegate keyword. This dictates what types of methods we can assign to the delegate. Similar to a function, a delegate has: a return type, a name, and a parameter list. The methods you want to add to this delegate must have both the same type of return type and parameter list. You then have to declare a member variable with the type of the delegate you created.
Example:
delgate void MyDelegate(int num)
MyDelegate myDelegate

Then, you can either assign methods to the delegate as values directly, or add/remove methods from the delegate with the += or -= operators respectively. Adding several methods to a single delegate is called multicasting.

The example from the Unity Official Tutorial I linked is as follows: using UnityEngine;
using System.Collections;

public class MulticastScript : MonoBehaviour
{
delegate void MultiDelegate();
MultiDelegate myMultiDelegate;


void Start ()
{
myMultiDelegate += PowerUp;
myMultiDelegate += TurnRed;

if(myMultiDelegate != null)
{
myMultiDelegate();
}
}

void PowerUp()
{
print (“Orb is powering up!”);
}

void TurnRed()
{
renderer.material.color = Color.red;
}
}

This shows the potential of a multicast delegate. On start, the PowerUp and TurnRed methods are both added to the myMultiDelegate delegate (which is possible since both methods have return type of void with no parameter list, just as the delegate does). Now anytime afterward, if the myMultiDelegate is called, it will perform all of the methods added to it (in this case both PowerUp and TurnRed). It is also noted that if you want to remove methods from myMultiDelegate, just use the -= operator along with the name of the method you want to remove.

One final note was that attempting to use a delegate that has not been assigned anything will cause an error. In this case, a delegate will have its default value, which is null. This is why they show in the tutorial that it is good practice to check that the delegate is !null before attempting to use it.

Events

Events: specialized delegates that are useful when you want to alert other classes that something has happened. An event can be thought of as a broadcast system. Any class interested in an event can subscribe methods to it. When that specific situation occurs, the event is invoked, which calls the methods of the subscribed classes. So an event is just like a delegate classes can send methods to, and then when that event is called, all of those methods will happen.

In the Unity Event tutorial I linked, they start by creating an EventManager script they place on the camera (this might be different with Event Systems now, this is an old tutorial). They then create a public delegate, which is then the type used for the public static event they create. So it appears that an event might be something similar to a list of delegates, and you add the type of delegate to it to determine what types of methods you can subscribe to this event. The tutorial then ties the event to a button press. Now any time this button is pressed, every method subscribed to the event will be invoked.

To show the broadcasting nature of events, there are two separate game objects with two separate scripts attached to them that subscribe different methods to the same event. They also show the proper fundamental practice of dealing with events. The scripts subscribe their methods to the event OnEnable, and unsubscribe them OnDisable (this is similarly does as with delegates; the += operator subscribes a method to an event, and the -= operator removes the method). It is a good rule of thumb that every time you subscribe a method to an event, you should create a corresponding unsubscribe for it as well. Failing to do this properly can lead to memory leaks and other various errors.

They then describe why this system is effect for dealing with action in your game. The event manager only needs to worry about the event itself and the triggers for the event. It does not need to know about the Teleport of TurnColor script, and these two scripts didn’t need to know about each other either. This helps create a flexible broadcast system.

They then describe the difference between using a public delegate and the event they created. They state that you could acheive the same effect this way, since events are just specialized delegates. The reason to use an event here is that they have inherent security. Events ONLY allow other classes to subscribe and unsubscribe. If a delegate was used, other classes could invoke it or overwrite it.

The take away: if you want to create a dynamic method system that involves more than one class, use event variables instead of delegate variables.

Unity ML Agents – Setup

March 15, 2019

Unity ML Agents

Balancing Ball Setup


Basic Project Settings

Make sure the “Scripting Runtime Version” for every platform you are targeting to build is set to (.NET 4.6 Equivalent or .NET 4.x Equivalent). I had to update the project to work with Unity 2018 and it already had .NET 4.x Equivalent as the default setting for all of my platforms.

Overall GameObject Hierarchy

The overall platform prefab has a “Ball 3D Agent” script which needs a brain property

The brain object then holds a Tensor Flow model property

Setting Up Training Environments

There are two ways to train your objects: in the Unity Scene Editor in by using an executable.

The first example will train in the Unity scene editor. This is done by accessing the “Ball 3D Academy” object, adding “3DBallLearning” brain to the Broadcast Hub of the “Ball 3D Academy” script, and checking the Control check box. The Broadcast Hub exposes the brain to the Python process, and the Control checkbox allows that Python process to control the brain.

Next I needed to use Anaconda Prompt to run the learning processes. Since I’m still getting the hang of this, I ran into a few basic issues noted in the PROBLEMS section.

After successfully completing the training, the trained model is located at path:

models/<run-identifier>/<brain_name>.nn

You then want to bring your model (the .nn file) into your Unity project, and then set this as the model property for the brain you are using.

Problems

Apparently I did not follow the default installation setup, so I was unable to access “mlagents-learn” from any directory. I found my ml-agents folder location and learned how to change my directory in Anaconda Prompt to get myself into the correct location. This then allowed the first step to properly process, which was running the line:

mlagents-learn config/trainer_config.yaml –run-id=firstRun –train

After resolving this step, I was getting a UnityTimeOutException error in Anaconda Prompt. This was just because Unity was unable to communicate with the Python process because I forget to check the Control checkbox from the tutorial.

Finally, when I went to add my newly trained model to the Learning Brain and play the scene, I got an error and the platforms did not move at all. I did not reopen the scene like stated in the tutorial notes, and determined a default value of the scene might have still been altered. It turned out I just needed to uncheck the Control check box in the Brain Hub, which makes sense since that determines if the platforms are run by the outside Python process or not. Turning this off allowed them to perform on their own with the designated model properly again.

NEXT STEPS

These are the next steps suggested by the end of this small setup tutorial:

Intro to Python Programming with Mosh – Pt. 02

Intro to Python Programming with Mosh – Pt. 02

March 14, 2019

Intro to Python Programming

Tutorial – 02

Youtube – Learn Python 3 for Machine Learning & Web Development [2019]

By: Programming with Mosh
Progress

End Time: 48:40

Next Part of Tutorial: Arithmetic Operations

NOTES

Strings

You can use single or double quotes for strings, but there is a difference for certain applications. For example, if you want an apostrophe in your string, you need to use double quotes to define the string. An example for the reverse is that you use single quotes to define the string if you want something to be in double quotes within the string.

Strings can also be defined with triple quotes. This allows you to create a multiline string.

You can call a character index of a string with brackets (i.e. string[0] will return the value of the first character in that string.). An interesting feature is that you can use negative indices to start at the end of the string and count backwards.

You can also call a chunk of characters with two values separated by a colon. If you don’t place a number before the colon, 0 will be assumed. If you don’t place a number after the colon, the length of the string is assumed. Using these together, you can perform a simple duplication of a string (i.e. another_string = string[:]).

The final check with this colon/index syntax was what would happen if you entered:
string[1:-1]
Where string was ‘Jennifer’. This returned ‘ennife’, which appears to indicate this syntax always returns values from left to right if possible, as well as showing that the beginning value is inclusive, while the final value is exclusive. To further test this, I tried string[3:1] and this did not return any value, which fit my thought on “left to right is possible”.

Formatted Strings

Formatted strings are used to make complex strings easier to visualize their output. Formatted strings are indicated with quotes starting with an f (i.e. f’text’). They then use curly brackets to create holes in the string where variables can be placed.

String Methods

The first basic method is len(). This returns the value of the number of characters in a string. This function is general purpose though, so it can count the number of objects in a list as well for example. The fact that it is general purpose is what makes it a function, as opposed to a method.

We looked into the find() method for strings. This takes an input of characters and returns the index of the first instance of those characters in the associated string. You can enter a single character or entire words to search for. Multiple characters will return the index of where those characters start.

The replace() method takes two inputs; the first input is what it searches for in the string, and the second input is what it replaces that with.

Next we used the “in” operator. Using the format of:
‘characters’ in string_variable
This returns a bool value of whether those characters are found within the string value indicated.

TERMINOLOGY

  • Method: in object oriented programming, a function that belongs to or is specific to some object

SUMMARY

The main difference between a function and a method is that a function is more general purpose, where as a method is something belonging to a specific type of object.

The string topics covered here gave me a lot of new information. I’m interested to see if there is any overlap with some of this in C# for Unity programming since there’s a lot of really helpful functions and methods covered. The formatted strings are especially nice to keep code nice and tidy instead of having those ugly string concatenation lines.