Forward March! Entering the Final 6 Weeks.

FINALLY! After somewhere around two weeks of consistent suffering due to the issues I have been having with Unity, I am able to say that I have conquered the beast and I can finally make forward progress.

The issue I was having was related to me trying to make my scripts interact with each other, mainly changing and checking variables in scripts. When done wrong, my code would infinitely error on me, saying that an object was not set to a single instance of a variable. Considering that I was working with two scripts that were each linked to 9 and 5 objects respectively, I figured that the code I used to call the script was not differentiating from the different instances that I had. It was that thought that pushed me to the limit attempting to fix the problem, and in order to explain how I fixed it, I would like to explain a bit about a concept that I learned about in Unity.

Components: In the Unity interface, a user has the ability to create objects of different types, shapes, and sizes. These objects do not have a lot of functionality at their original creation. This gives the developer complete freedom when giving certain objects specific properties. From applying physics to the infinite imagination that comes with the creation of your own scripts, components are the backbone of functionality in the Unity framework. When working with your own scripts, you are able to call upon any of these components that are attached to individual objects.

This is where the coding concepts began to lose me. In order to pull information from an objects component, a developer will need to first locate the object that the component is attached to and save a reference to it locally in that script. Once the object is locally saved, you must then reference the specific component that is holding the information that you need in your current code. After saving a reference to the specific component, all public variables of that component will be accessible in that local version of the script. A variable can dynamically change across scripts. Using this method will allow multiple scripts to make use of the same variable, giving you flexibility when writing new scripts by being able to reuse old methods and variables.

What I learned: In hindsight this concept makes complete sense to me, and it took me a ton of trial and error, countless hours reading materials on Unity, and watching tutorials to understand where the problem lay in my logic. I have lost a lot of ground due to this and I anticipate that my scope will need to be redefined when I have the chance. Although I may have gotten more familiar with the Unity Interface, I still have a long way to go if I am going to have a working game by mid-December. Only six weeks left for me to work on the project, I have to make every second count now!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s