Catlike Coding - Basics Flashcards

1
Q

DateTime time = DateTime.Now;

  1. Is DateTime a class or a struct?
  2. In which namespace can it be found?
  3. What is “Now”?
  4. What does “Now” return?
A
  1. DateTime is a struct
  2. In System namespace
  3. “Now” is a static property (a method that acts as a var)
  4. It contains current time.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What’s a property?

A

A property is a method that pretends to be a variable.

It might be read-only or write-only.

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

What is the difference between Transform.localRotation and Transform.Rotation?

A

Transform.localRotation is the rotation of an object relative to its parent container.

Transform.Rotation is the rotation of an object relative to the world root. (Good time to look into Quaternion.identity)

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

What’s a MonoBehaviour?

A

MonoBehaviour is a class from the UnityEngine namespace.

If you create a class that you want to use as a Unity component, then it should inherit from MonoBehaviour.

It contains a lot of useful stuff and makes things like Update work.

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

What is the use of Quaternions?

Is Quaternion a struct or classs?

Unity Internally uses Quaternions to represent most rotations (T/F ?)

A

Quaternions are used to represent rotations.

The UnityEngine namespace contains the Quaternion struct.

False. Unity internally uses Quaternions to represent all rotations.

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

What is the use of creating Transform variables and which transform variables would you be able to access?

A

Transform variables are used to access the Transform companent of any object in your scene.

You would be able to access any Transform component of any object in your scene.

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

How do you rotate an object around itself.

A

Transform.localRotation = Quaternion.Euler(float x, float y, float z);

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

What are properties? (Unity’s definition - can be referred to as component properties) This could be false / no longer named as property.

A

Variables exposed by the Unity editor.

In Layman’s terms: The thing that appears in Unity editor when you create a public variable which allows you to set variable.

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

What’s a class?

A

A class is a blueprint that can be used to create objects that reside in your computer’s memory.

The blueprint defines what data these objects contain, and how they behave.

A class is cookie cutter, the object is a cookie.

A class is the instructions of the receipe, the object is the dish.

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

What does Transform.localRotation = Quternion.Euler(x, y, z) do?

A

It changes the rotation of the Transform relative to its parent.

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

What is Quaternion.Euler(float x, float y, float z)

A

A Method in Quaternion which returns a rotation that rotates z degrees around the z axis, x degrees around the x axis, and y degrees around the y axis (in that order).

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

What’s a namespace?

A

It’s like a website domain, but for code stuff.

For example, MonoBehaviour is defined inside the UnityEngine namespace, so it can be addressed with UnityEngine.MonoBehaviour.

By declaring that we’re using a namespace, we don’t need to write it again each time we want to use something from it.

So, when using UnityEngine, instead of having to write UnityEngine.MonoBehaviour we can suffice with MonoBehaviour.

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

Does Unity have a right-handed or a left-handed coordinate system?

A

Left-handed.

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

How do you rotate an object around another point?

A

Put your object in an empty container and apply localRotation to that container. Your child object is essentiaily attached to it.

Imagine a merry go round.

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

What’s a child object?

How does the transformation behave with relation to:

  1. Inhertance of transformation
  2. Position
  3. Rotation
  4. Scale
A

If you put an object inside another (by dragging in the Hierarchy view) then it’s considered the child of the object that now contains it.

The transformation of the parent is inherited by its children and is applied first. So if the child’s transform’s position is set to (10, 0, 0) while the parent’s is (2, 1, 0), then the child will end up at (12, 1, 0).

If the parent’s transform’s rotation is set to (0, 0, 90) as well, the child effectively orbits its parent and ends up rotated (0, 0, 90) at position (2, 11, 0).

Scale is inherited in the same fashion.

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

What is a GameObject?

A

Everything that’s placed in a scene is a GameObject.

It has a name, a tag, a layer, a Transform component, and can be marked as static.

By itself it doesn’t do anything, it’s just an empty container. You can turn it into something useful by attaching components to it and by putting other objects inside it.

17
Q

How do you get analog time? (fractional time values).

What type of values are returned?

A

Create a TimeSpan variable (as TimeSpan is a struct) initialized it to DateTime.Now.TimeOfDay

ie TimeSpan timespan = DateTime.Now.TimeOfDay;

Note: Values are provided in doubles, you may need to cast them as floats.