Classes For Behavior!

addam davis
2 min readJul 21, 2021

--

Objective: Describe and understand what Classes are.

What is Monobehavior? Monobehavior gives you the ability to attach a script to objects. MonoBehavior is, as the name suggest, for behaviors.

One of the great things about classes is, it is a crucial element to what is called Object Oriented Programming also known as OOP. In Object Oriented programming the premise is you can create clean modular programs that are organized well. Classes allow us to do just that.

We can break functionality into separate classes and within these classes you can have fields and methods related to individual features.

We do this because it is easier to debug and maintain. If you have a bug with the player’s movement, it will be easier to find the issue of the movement is its own method.

We open the method that is related to our bug, and we can easily see the issue. In the example above, a typo is the source of the error and easy to fix.

Proper Object Orientation Programming techniques is to have feature in their own methods. I.e., shooting in its own method, movement in its own method.

That’s it, that is the basics of a class, and Object Orientation Programming. In the next tutorial we will discuss custom classes, what they do and how to use them. I’ll see you in the next tutorial!

--

--