1/99
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
Semicolon
Every line of C# is called a statement and must end with a to separate them for the code complier process
public int myAge = 16;
Variable
a tiny section of your computer's memory that holds an assigned value. Every variable keeps track of where its information is stored (this is called a memory address), its value, and its type (for instance, numbers, words, or lists).
Operators
A symbol that tells the compiler to perform specific mathematical or logical manipulations.
Methods
can perform an operation and return the result. For instance, a _ can add numbers, return the sum, and store the sum in a variable.
Control-Flow
One of the central duties of a computer is to control what happens when predetermined conditions are met. When you click on a folder, you expect it to open; when you type on a keyboard, you expect the text to mirror your keystrokes. Writing code for applications or games is no different - they both need to behave in a certain way in one state and in another when conditions change.
Selection Statement
The if-else and switch selection statements allow you to specify branching paths, based on one or more conditions, and the actions you want to be taken in each case. They include the following
if-else
statement is the most common way of making decisions in code.
For example, if my condition is met, execute this block of code; if it's not, execute this block of code.
Arrays
_ are the most basic collection that C# offers. Think of them as containers for a group of values, called elements in programming terminology, each of which can be accessed or modified individually
Lists
collecting multiple values of the same type in a single variable. They are much easier to deal with when it comes to adding, removing, and updating elements, but their elements aren't stored sequentially. This can, sometimes lead to a higher performance cost over arrays
Performance cost
refers to how much of a computer's time and energy a given operation takes up.
Dictionaries
To initialize a dictionary with key-value pairs, do the following
Classes
blueprints for objects and can be treated as custom variables and are reference types
Structs
are like classes, they are blueprints for objects, the difference is that they are value types
OOP
Object Oriented Programming is the concept of using objects as parent containers made up of multiple components
Where is OnTriggerEnter called?
In the FixedUpdate
What does the Hierarchy window contain?
A list of every GameObject in the current scene
What is the topmost GameObject on the Hierarchy called? What are the GameObjects below called?
the Parent/ Children or ChildObjects
What does the Game View Window display?
A representation of our game when running in Play Mode.
What does the display drop-down may do?
It allows us to select different values to see how it will look on devices with different aspect ratios and resolutions. You wouldn't want distortion or a menu to be cut off.
Scale slider
Allows you to zoom in and examine areas of the Game View Window in more detail.
Stats button
Toggles the statistics overlay containing rendering statistics about our game's audio and graphics to monitor the performance of our game while in play mode.
What does the Gizmos button do?
It enables the visibility of gizmos, used to give visual debugging or setup aids in the game view.
Project window
allows us to easily access and manage all our assets in our project.
= operator
Assigns the value of the right-hand operand to the object denoted by the left-hand operand.
How is an operator null?
If the variable does not use an assignment operator, such as =, then the variable is null.
>
Greater than
<
Less than
=
Greater than or equal to
<=
Less than or equal to
==
Equal to
!=
Not equal to
!
Not
&&
And
II
Or
++ (example i++)
Increments by 1
-- (example i--)
Decrements by 1
%
Remainder, also known as Modulus
Where can scripted variables be edited?
They can edited in the Inspector window; however, the access modifiers must be declared as public for them to appear in the Inspector window
(True or False) A variable is declared private. It appears in the inspector menu.
False
How is a private variable accessed locally?
Within the PlayerController class.
NullReferenceException
A procedure is called when the result is not possible
Animation Parameters
(Used to communicate between scripting and the Animator Controller) Variables that are defined within an Animator Controller that can be accessed and assigned values from scripts.
SetFloat
A number with a fractional part
SetTrigger
A whole number
SetBool
True or false value
SetFloat Example
("Forward", 10.0f)
SetInteger Example
("Forward", 5);
SetBool Example
("Forward", false);
Example of a SetTrigger animation function
SetTrigger("Die");
//
Single line comment
/* */
Multiple line comment
Public
The access modifier, access modifiers are applied to the declaration of a class, method, properties, fields, and other members. They define the accessibility of the class and its members. Public private, protected, and internal are access modifiers in C#.
Void
The return type; void is used where there is no data. For example, if a method does not return any value then you can specify void as a return type.
MyMethod
The method (function) name, followed by parenthesis with two parameters we pass, int and string are the parameter type and parameter1 and parameter2 are the parameters' name.
How are Awake and Start similar?
They're two of the first few functions called when a script is activated, only called once, and are used to initialize the script.
Why would someone use the Awake function?
They would use Awake to initialize a script using only itself and its game object
Why would someone use the Start function?
They would use Start to further initialize based upon values in other scripts. For example, say we have a PlayerScript and a ShieldScript
OnEnable
is like Awake and Start, but it is called every time the script is activated. This makes it an ideal place for subscriptions or other initialization done on each activation. If you put subscriptions in OnEnable and unsubscribe during OnDisable, you can avoid extra code execution on unused objects.
Why is Init seen as superior compared to the other methods?
None of the other methods are called until the game object is activated.
Input.GetButton
Input.GetButtonDown, and Input.GetButtonUp are public static bools (true or false).
Input.GetButton
returns true when the button has been pressed, held down, and not released. It will return false when the button is released.
Input.GetButtonDown
returns true during the frame the user pressed down on the button. It will not return trueuntil the user has released the key and pressed it again.
Input.GetButtonUp
returns true during the frame the user releases the button. It will not return true until the user has pressed the button and released it again.
Input.GetMouseButton(int button)
Input.GetMouseButtonDown(int button);, and Input.GetMouseButtonUp(int button);, and work similarly to the Input.GetButton methods. They are public static bools (true or false).
Input.GetMouseButton(int button)
returns true while the given mouse button is pressed down and held down.
Input.GetMouseButtonDown(int button)
returns true during the frame the user pressed down the given mouse button.
Input.GetMouseButtonUp(int button)
returns true during the frame the user releases the given mouse button.
Input.GetKey
Is a public static bool (true or false). Returns true while the user holds down the key identified by name.
Input.GetKeyDown
Is a public static bool (true or false). Returns true during the frame the user starts pressing down the key identified by name.
Input.GetKeyUp
Is a public static bool (true or false). Returns true during the frame the user releases the key identified by name.
What can Input.GetKey be used for?
It can be used as a parameter to the method(function) to detect and return true when the user presses the up arrow key, down arrow key, left arrow key, or right arrow key.
For loop
Executes a statement or code block multiple times using the for loop, structure of the for loop, nested for loops, and how to exit from the for loop.
Initializer
Used to initialize a variable that will be local to a for loop and cannot be accessed outside loop. It can also be zero or more assignment statements, method call, increment, or decrement expression e.g., ++i or i++, and await expression.
Condition
The condition is a boolean expression that will return either true or false. If an expression evaluates to true, then it will execute the loop again; otherwise, the loop is exited.
Iterator
Defines the incremental or decremental of the loop variable.
What can Animator.SetBool be used for?
To pass Boolean values to an Animator Controller via script.
Random.Range
Returns a random float number between and min [inclusive] and max [inclusive]
What does _Color do?
It sets a color to an object
What is an example of a code bing used to set a color to an object?
("_Color", Color.red);
When is OnCollision called?
Called when this collider/rigidbody has begun touching another rigidbody/collider. Incontrast to OnTriggerEnter. Is not a collider.
When is OnCollisionStay called?
Called once per frame for every collider/rigidbody that is touching rigidbody/collider. In contrast to OnTriggerStay. Is not a collider.
When is OnCollisionExit called?
Called when this collider/rigidbody has stopped touching another rigidbody/collider. In contrast to OnTrgiggerExit. Is not a collider.
When/Where is OnTriggerEnter called?
When a GameObject collides with another GameObject. It happens on the FixedUpdate function.
When is OnTriggerExit called?
When the Collider other has stopped touching the trigger.
When is OnTriggerStay called?
Almost all the frames for every Collider other that is touching the trigger. The function is on the physics timer, so it won't necessarily run every frame.
What is Transform.position?
The Vector 3 position, the position of the GameObjects transform in world space.
What is Vector3.zero?
It's shorthand for Vector3(0, 0, 0)
How do I rotate an object in code?
Use Transform.Rotate
How do I rotate using Euler angles?
Using Transform.eulerAngles
When using any variance of Input.GetMouseButton, what does 0 , 1 , and 2 mean?
Left button, right button, middle button