ChatGPT Unity C# Training Flashcards

(24 cards)

1
Q

What is C# in Unity?

A

C# is the language you use to tell Unity what your game should do.

Explanation:
Unity is the game engine, and C# is the language you use to give it instructions. Unity gives you the world and the tools. C# tells those tools how to behave.

Real-life example:
Think of Unity like a kitchen full of appliances and tools. C# is the recipe telling you what to do with them.

Game example:
In a Stardew-like game, C# tells the player how to move, when a crop grows, when gold increases, and when a menu opens.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a script in Unity?

A

A script is a C# file that holds instructions for your game.

Explanation:
A script is where you write your game logic. It is the container that holds your code. You usually attach scripts to GameObjects so those objects can do things.

Real-life example:
A script is like a note card with instructions written on it. The card itself holds the instructions.

Game example:
You might have a PlayerMovement script that tells the player how to walk, or a CropGrowth script that tells crops how to grow over time.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a variable?

A

A variable is a named box that stores information.

Explanation:
A variable holds a piece of data so your game can remember and use it. The name tells you what the information means, and the value is the information inside.

Real-life example:
A labeled jar that says “sugar” is like a variable. The label is the name, and the sugar inside is the value.

Game example:
A variable could store the player’s gold, health, energy, or number of seeds.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is a value?

A

A value is the actual information stored inside a variable.

Explanation:
The variable is the container. The value is what is inside that container. If the variable is called playerGold, the value might be 250.

Real-life example:
If you have a box labeled “apples,” the apples inside are the value.

Game example:
If a variable is storing crop count, the value might be 12 because the player has 12 parsnips.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is a data type?

A

A data type tells the computer what kind of information a variable is allowed to store.

Explanation:
The computer needs to know what kind of thing it is working with. Is it a whole number, a decimal, text, or true/false? The type sets the rules for what can go into the variable.

Real-life example:
Different containers are made for different things. A gas tank holds gas. A water bottle holds water. You would not store soup in a mailbox.

Game example:
A player’s name would be text. A player’s gold might be a whole number. A “hasWateringCan” check would be true or false.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is an integer?

A

An integer is a whole number with no decimal.

Explanation:
Integers are used when you want clean, full numbers. No halves, no fractions, no decimal points.

Real-life example:
If you have 5 apples, that is an integer. Not 5.7 apples.

Game example:
In a Stardew-like game, your gold, wood count, stone count, or inventory slot number could be integers.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is a float?

A

A float is a number that can have a decimal point.

Explanation:
Floats are useful when numbers need to be more exact and not just whole numbers.

Real-life example:
A bottle might hold 1.5 liters of water. That is not a whole number, so you would use a float.

Game example:
A player’s movement speed might be 3.5. A crop might grow by 0.25 progress per second.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is a string?

A

A string is text.

Explanation:
Strings store words, letters, names, and sentences. If it is text instead of a number, it is usually a string.

Real-life example:
A person’s name written on a name tag is text, so that would be a string.

Game example:
The player’s farm name, item name, NPC dialogue, or quest title could all be strings.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is a bool?

A

A bool is a value that can only be true or false.

Explanation:
A bool is used when something only has two choices: yes or no, on or off, open or closed, true or false.

Real-life example:
A light switch is either on or off. That is bool thinking.

Game example:
A game might check isWatered, isDead, hasKey, or shopIsOpen. Those are all true/false checks.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What does true mean in code?

A

True means “yes, this condition is correct.”

Explanation:
When something is true, the computer treats it like a condition that passes. It means the thing being checked is happening or exists.

Real-life example:
“Is the door open?” If the door is open, the answer is true.

Game example:
If the player has a fishing rod, then hasFishingRod would be true.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What does false mean in code?

A

False means “no, this condition is not correct.”

Explanation:
When something is false, the computer treats it like a condition that does not pass. It means the thing being checked is not happening or does not exist.

Real-life example:
“Is the store open?” If the store is closed, the answer is false.

Game example:
If the crop has not been watered yet, then isWatered would be false.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is a function?

A

A function is a named job that tells the computer to do something.

Explanation:
A function is a block of action. You give it a name so you can use it when needed. Instead of rewriting the same action over and over, you make a function once and call it when you want that action to happen.

Real-life example:
A button on a washing machine starts a job. Pressing that button triggers the machine to do its task.

Game example:
A function might water a crop, open a chest, deal damage, or add gold to the player.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What does it mean to call a function?

A

Calling a function means telling it to run.

Explanation:
The function already exists, but nothing happens until you use it. Calling it is like pressing the button that starts the action.

Real-life example:
Owning a blender is not the same as turning it on. Calling a function is like pressing the power button.

Game example:
When the player clicks a crop with a watering can, the game may call the function that waters the crop.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is a parameter?

A

A parameter is a piece of information a function expects to receive.

Explanation:
Some functions need extra information so they know how to do their job. A parameter is the placeholder for that information.

Real-life example:
If someone says, “Set the oven to ___ degrees,” the blank space is like a parameter.

Game example:
A damage function might need to know how much damage to deal. That amount would be a parameter.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is an argument?

A

An argument is the actual value you give to a function when you call it.

Explanation:
A parameter is the empty labeled spot. An argument is the real value you put into that spot when the function runs.

Real-life example:
If the instruction says “Set the oven to ___ degrees,” and you choose 400, then 400 is the argument.

Game example:
If a function needs damage amount, and you give it 10, then 10 is the argument.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the difference between a parameter and an argument?

A

A parameter is the placeholder. An argument is the real value you put into it.

Explanation:
This is one of those word pairs that confuses people, but the idea is simple. The function is built with parameters. When you use the function, you send arguments.

Real-life example:
A form asking for “Name” has a placeholder field. The actual name you type into it is the argument.

Game example:
A function may expect an item name as a parameter. When you send “Turnip Seeds,” that text is the argument.

17
Q

What is an if statement?

A

An if statement checks if something is true before doing an action.

Explanation:
An if statement is a decision-maker. It only runs its action if the condition passes. If the condition is false, it skips that action.

Real-life example:
If it is raining, bring an umbrella. If it is not raining, do not bring one.

Game example:
If the player has enough energy, they can swing the axe. If not, the action does not happen.

18
Q

What is a condition?

A

A condition is the test inside an if statement.

Explanation:
The condition is the question being asked. It must end in a yes or no answer, meaning true or false.

Real-life example:
“Is the fridge open?” is a condition because it can be answered with yes or no.

Game example:
“Does the player have 50 wood?” is a condition the game can check before letting the player craft a chest.

19
Q

Why are bools important for if statements?

A

Bools are important because if statements need a true or false answer.

Explanation:
An if statement cannot make a decision unless the condition can be checked as true or false. Bools are built for that kind of decision.

Real-life example:
A security gate opens only if the answer to “Is this badge valid?” is yes. That is a bool-style check.

Game example:
If shopIsOpen is true, the player can buy items. If it is false, the shop stays closed.

20
Q

How do variables, values, and data types relate to each other?

A

A variable is the named container, the value is what is inside it, and the data type says what kind of thing can go inside.

Explanation:
These three ideas work together. The variable gives the data a name. The value is the data itself. The type tells the computer what kind of data it is dealing with.

Real-life example:
A labeled milk jug works like this: the jug is the variable, the milk is the value, and the jug type tells you it is meant to hold liquid.

Game example:
A variable called playerName could hold the value “Sam,” and its data type would be string because it stores text.

21
Q

How do functions, parameters, and arguments relate to each other?

A

A function is the job, parameters are the information it expects, and arguments are the real values you give it.

Explanation:
A function often needs extra details to do its job correctly. Parameters are the empty slots for those details. Arguments are the actual values placed into those slots when the function runs.

Real-life example:
Ordering food works like this: the order system is the function, the menu choices are the parameter slots, and your actual choices are the arguments.

Game example:
A function that gives the player an item may need the item name and amount. Those are parameters. Sending “Stone” and 20 would be the arguments.

22
Q

How do if statements and bools relate to each other?

A

An if statement uses a bool result to decide whether to run an action.

Explanation:
The if statement asks a yes/no question. The bool answer tells it what to do next. True means go ahead. False means do not.

Real-life example:
If the answer to “Is the key valid?” is yes, the lock opens. If not, it stays locked.

Game example:
If hasBarnKey is true, the player can enter the barn. If it is false, the door stays shut.

23
Q

Why are variables and functions both important?

A

Variables store information, and functions use that information to make things happen.

Explanation:
Variables are the memory. Functions are the actions. Most game logic is these two things working together. The game remembers data, then does something based on that data.

Real-life example:
A recipe needs stored ingredients and also cooking steps. The ingredients are like variables. The cooking steps are like functions.

Game example:
A variable stores the player’s energy. A function checks that energy and lets the player chop wood if they have enough.

24
Q

What is game logic?

A

Game logic is the set of rules that controls how the game behaves.

Explanation:
Game logic decides what happens, when it happens, and why it happens. It is the “brain rules” of the game.

Real-life example:
The rules of a board game are its logic. They decide what players can do and what happens next.

Game example:
In a Stardew-like game, game logic decides when crops grow, when shops open, when stamina goes down, and when the day ends.