Catlike Coding - Basics Flashcards
DateTime time = DateTime.Now;
- Is DateTime a class or a struct?
- In which namespace can it be found?
- What is “Now”?
- What does “Now” return?
- DateTime is a struct
- In System namespace
- “Now” is a static property (a method that acts as a var)
- It contains current time.
What’s a property?
A property is a method that pretends to be a variable.
It might be read-only or write-only.
What is the difference between Transform.localRotation and Transform.Rotation?
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)
What’s a MonoBehaviour?
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.
What is the use of Quaternions?
Is Quaternion a struct or classs?
Unity Internally uses Quaternions to represent most rotations (T/F ?)
Quaternions are used to represent rotations.
The UnityEngine namespace contains the Quaternion struct.
False. Unity internally uses Quaternions to represent all rotations.
What is the use of creating Transform variables and which transform variables would you be able to access?
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 do you rotate an object around itself.
Transform.localRotation = Quaternion.Euler(float x, float y, float z);
What are properties? (Unity’s definition - can be referred to as component properties) This could be false / no longer named as property.
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.
What’s a class?
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.
What does Transform.localRotation = Quternion.Euler(x, y, z) do?
It changes the rotation of the Transform relative to its parent.
What is Quaternion.Euler(float x, float y, float z)
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).
What’s a namespace?
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.
Does Unity have a right-handed or a left-handed coordinate system?
Left-handed.
How do you rotate an object around another point?
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.
What’s a child object?
How does the transformation behave with relation to:
- Inhertance of transformation
- Position
- Rotation
- Scale
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.