Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Beginning C# with Unity: Variables

One of the key aspects of creating games is managing state. State persists throughout an entire game. It requires the computer to remember lots of different pieces of information. You do this in Unity by defining c# Variables.

Take Pac-Man, for example. In that game, the computer needs to remember how many people are playing the game. Is it a single player game or are two players involved? Who is the active player? What is their current score?

Then there is the game itself. How many dots are there in the maze. How many ghosts are chasing Pac-Man? Has Pac-Man recently eaten a power pellet? In fact, where is Pac-Man in the maze? And so on and so forth

The game manages a ton of other data points “behind the scenes” by way of variables. This provides a consistent frame rate as well as music and sound effects. All done with variables which you’ll learn in this episode.

In this episode

Variables are a fundamental component in writing C#. In this episode, you’ll learn how to define a C# variables in code. This means learning keywords in the C# language. The video also teaches you the concept of types and their differences.

As you learn these concepts, you’ll also learn how to access your variables in the Unity editor. Unity uses something known as “access control” to expose variables. This allows you to change variables as your game is being played.

For instance, in the case of Pac-Man, you add more ghosts by simply adjusting a value. This allows you to rapidly iterate on your game. You’ll be able to change your game’s state as you play it. Mind you, all your changes are lost once you stop the game but there are ways to make it persist. This is beyond the scope of this video.

Other Links

To see other episodes hosted on Jezner, check out the Beginning C# hub.
To watch the complete playlist on YouTube, check out my Vegetarian Zombie C# playlist.

The post Beginning C# with Unity: Variables appeared first on Jezner Blog.



This post first appeared on Jezner - Old Time Radio, please read the originial post: here

Share the post

Beginning C# with Unity: Variables

×

Subscribe to Jezner - Old Time Radio

Get updates delivered right to your inbox!

Thank you for your subscription

×