Building Scripting Skills

GetKeyDown(KeyCode.[Key on keyboard]) is how you make keys operate function in code with an if statement.

Drag and drop C# scripts to add to object.

“Add component” can create and add a C# script at the same time.

int = integer

int myInt = 5; means I want the integer 5.

Maintains value until assigned a new one.

Void doesn’t return values.

parameterName can put in parameters to what integer can appear.

Ret = return a number

Debug.log is console window

Syntax: structure of language

. Separates things that are sub of each other, think of country.city

; terminates, so use at end except for }

Indent to organize

//this is a normal one line comment

/* this is a

*two line comment

Java uses less lines, c# more specific

Default is different, c# is private, java is public

If chooses one or another depending on certain things that can happen

Else is what happens if it is false

  • Loops
    • Link: loops (5:33)
    • Notes:

While happens until parameter is false

Do while is at end while while in at start, so do while always happens once.

Do while has semicolon at end

for does certain loops for certain parameters in increments

For each loops through items of an array until there are no more items

Classes are where functions happen

Organize different functions into different classes for organization

Constructor gives default values for variables and it’s end syntax is ()

() is for parameters

Parameters are for new objects

Spinning Cube and Simple Clock

Spinning Cube Tutorial:

Clock Tutorial:

https://unity3d.com/learn/tutorials/topics/scripting/simple-clock

My Explanation Video:

https://youtu.be/-WexvD3QfRY

Scripting Resources:

Manual: https://docs.unity3d.com/Manual/GameObjects.html

This Gives an in depth explanation of GameObjects and how they work inside Unity.

Scripting: https://docs.unity3d.com/ScriptReference/GameObject.html

This showcases a lot of different functions for scripting and each link explains what each function does.

What I Learned:

I learned how to code different objects into being able to rotate at different speeds and directions, as well as have them move to the actual time as shown with the clock.