C# Script Notes I

public float 
The term public will make it adjustable on the Unity inspector meaning that we can change the value there instead of in the C# script.

For the variable float, we would need use the a decimal value and end with f.

/* multi land command */
// single line command

print (check console)

Variable types
int = integer (whole numbers)
bool = boolean (true or false)
string = collection of characters

Arithmetic Operators
+ Addition
- Subtraction
* Multiplication
/ Division

Comparison Operators
== is equal to
! = not equal to 
> larger than
< less than
> = larger than or equal to
<= less than or equal to

Switch Statement

switch (weapon)
{
  case 1:
   print ("You found life");
   break;

  case 2:
   print ("You found nothing");
   break;

  case 3:
   print ("You found greatness");
   break;

  default:
   print ("You found ______ ");
   break;
 }

default is used when there's nothing else

Naming Convention
FirstCapital: Function
secondCapital: Variable

void: function
start (at the start of the game)
update (every frame in the game)

custom (); to execute play/use it.

call upon by key (Input Manager)
if (Input. GetKeyUp ("space")) {
custom ();
}

Vector 3 (x,y,z)

Tags:

Share:

0 comments