Dev Update 11/6/18


A lot has gotten done this week on the first shooting gallery, so lets start off with a high-res screenshot.


So what’s working right now? Pretty much everything. Which is awesome.

Game Time w/ Fastest Time

A word of advice to new coders – make sure that what you’re editing isn’t being used elsewhere…

I have two scripts, one named Timer, and the other named NewTimer. Half way through modifying Timer to do what I want, I realized that I’d changed it so far from what it was originally that it could no longer be utilized for the first arena sequence. It’s not the biggest of deals, since the new one is better and more versatile. So how does it work?

The first thing that has to happen is that the player has to hover their mouse over the console you see on the screen, thus triggering an OnMouseOver() function that triggers an animation. On the key press, a 3-2-1-Go animation triggers, with a chime on each number. That was surprisingly hard to build. First, I had to figure out how to reference the individual text objects, to which I built this monstrosity

Yes, it keeps going…

So all of the HUDCanvas text elements are stored in an array called hudText[]. I didn’t know what the value was in the string, so I just wrote what I knew, which was I could get Debug.Log(“”) to print back out the name of whatever text object was in the array, and I want to say that originally the items I needed to change were 9,10,11, and 12. Great? Wrong. I got the function working, but then I moved an element in the HUDCanvas, and it shifted the value in the array, so I had to go back and figure out what the new values were. Total pain. Which leads us to…

Again, another challenge to get working well.

So, the text within the animator only has a few values modified. X position, Y position, and Alpha. hudText[].color.a grabs the alpha value and returns true when that value is equal to or greater than “0.9”. That part is actually pretty important. The reason the threshold is set so high is because due to it’s placement in void Update(), it doesn’t have time to refresh for every value change, only every frame, so setting it to == 1 meant that it would never fire, and lower than say, 0.5, would mean that it would be firing before the text was at 100% opacity, which doesn’t look or sound right. The highest value that I saw was .999946…

It won’t stay this way, as I’ll be trying to migrate the bulk of these events to the Game Controller script I started working on a while back.

So on to the timer.


This code lives inside a function called StopTimer(), that fires either manually through a keypress on the in game console, or when the game is finished.

Earlier in the script, the nuts and bolts of the timer control a float called time, which is a float that increases in direct correlation to Time.deltaTime.

I set currentTime = time, and when the function StopTimer() is used, it checks to see if the currentTime is less than or equal to a float called “BestTime”, which is stored in PlayerPrefs (Learn about this if you want to make leaderboards.) If none exists, currentTime is equal to currentTime, which it then sets as “BestTime” via PlayerPrefs.SetFloat(“BestTime”, currentTime”)

It’s not formatting the best time correctly just yet, but I still don’t understand everything about formatting strings. Anyway, I’ve got to go take an accounting test, but I hope that you’ve enjoyed this update as much as I’ve enjoyed coding the update, and if you want to see more code like this, leave a comment with what you’d like to see and I’ll put it in the next update!



Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )

Connecting to %s