![]() In the code above, we are first setting _weaponHP variable to 100, when we declare and initialize it.Īfter that, in the start method we overwrite 100 with 92, which is the output of Calculation 100 – 8. Using the Subtraction Arithmetic Operator you can subtract two numbers as you can see in the Code example above. _weaponHP = _weaponHP - 40 // Now _weaponHP is 92 - 40 = 52. Next, we use the data stored inside _playerHP which now is 27 and perform addition again with 40 giving us the result of 67, which we set to the _playerHP variable.Īrithmetic Operator | Subtraction Operator ( – ) // Everything Below is inside a Class. In the code above, we are first setting _playerHP variable to 250, when we declare and initialize it.Īfter that, in the start method we overwrite 250 with 27, which is the output of Calculation 25 + 2. Using the Addition Arithmetic Operator you can add two numbers as you can see in the Code example above. _playerHP = _playerHP + 40 // Now _playerHP is 27 + 40 = 67. In C# there are 7 Arithmetic Operators that you will find useful as a Game Developer :Īrithmetic Operator | Addition Operator ( + ) // Everything Below is inside a Class. So, Let’s get started with Arithmetic Operators. In which i talk about the things i personally think about when I’m evaluating whether a Game Idea is worth pursuing or not. If you are interested in Game Development then you might like this article on 3 Points To Consider Before Committing To A Game Idea. If you are new to Game Development or Programming in general you should definitely go through this Unity Tutorials article series as it will set give you a kick-start towards becoming an exceptional Unity 2D or 3D Video Game Developer. ![]() This Post is Part of : How To Make A Game Series where i’ll be showing you how to become a game developer and will be going over the basics of Game Development, Step by Step, using the Unity Game Engine and C# Scripting Language to script the Game Logic. In this article, we are going to cover Arithmetic Operators and then in subsequent articles we will cover the Assignment Operators, Comparison Operators and Logical Operators. ![]() These symbols are what we call Arithmetic Operators in programming and you can basically consider them staples of the programming world. In C# and all the other programming languages, we use special symbols for performing Mathematical / Arithmetic Calculations.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |