Unity Basics Flashcards

1
Q

How do you add physics to a gameobject?

A

Add a rigidbody component

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

When is FixedUpdate called?

A

Before performing any physics calculations

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

When is Update() called?

A

Before rendering a frame

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

What is an easy way to have the camera follow a gameobject?

A

Make the camera a child of the gameobject

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

Which Update() is best used to follow cameras, procedural animations, and gathering last known states?

A

LateUpdate()

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

What is a prefab?

A

A prefab is an asset that contains a template or blueprint of a game object or game object family

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

What happens when you make a change to a prefab?

A

All of the prefab instances in the game will be updated with the changes.

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

How to make a game object dynamic?

A

Add a collider and a rigid body

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

What determines whether a collider is static or not?

A

Whether or not it has a rigid body

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

How do you prevent an object with rigid body from reacting to physics?

A

Make the rigid body kinematic

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

If a collider is moving or rotating (not static like a wall), what should you do to prevent the collider from being cached every frame?

A

Make the collider dynamic by adding a rigid body

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

How are kinematic rigid bodies moved?

A

By manipulating their transform

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

How do you use a mesh collider alongside a rigid body?

A

Mark it as convex

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

how would you write the value of a 0.0 float in unity c#?

A

0.0f

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

How would you make a custom class visible in the inspector and usable by other classes?

A

Add [System.Serializable] before the class

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

Name a shader that would remove black from a material (transparent)

A

Particles/Additive

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

What is the point of using mobile shaders?

A

They are a more efficient use of resources

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

What are the disadvantages of using mobile shaders

A

You lose some quality and control

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

How would you get the input key R?

A

Input.GetKeyDown(KeyCode.R)

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

How do you pivot around a selected object with camera?

A

Select an object and press F to focus on it. Then, you use the orbit tool, to rotate around that object (and its children).

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

Describe an easy way to add a texture to a material

A

Change shader to legacy/diffuse and then you can add a texture

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

What is directional light mainly used for

A

A global lighting such as the sun or moon.

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

What does the UV in UV mapping stand for?

A

X,Y and Z are spacial co-ordinates while U,V,W are surface/mesh co-ordinates. This process projects a texture map onto a 3D object. The letters “U” and “V” denote the axes of the 2D texture because “X”, “Y” and “Z” are already used to denote the axes of the 3D object in model space.

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

What are the two main ways that programs can respond to changes in the world?

A

Polling and Events

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

How do you setup the EventSystem to raycast out into the scene?

A

By adding a Physics Raycaster to the camera

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

How to make a variable public in a script but hide it in the inspector?

A

Add [HideInInspector] before the variable

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

What do you do if the pivot will not change on an element?

A

Change the Tool Handle mode to Pivot instead of Center

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

How do you change an image file (png/jpg) to a sprite?

A

Change Texture type to Sprite (2D and UI) and apply

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

If a room or structure is not casting a shadow, why is this happening and how can you fix this?

A

It’s happening because the normals are flipped. You can fix this by creating a box around it with the normals flipped the other direction

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

What is Volumetric lighting?

A

Volumetric lighting is a technique to add lighting effects that allow the viewer to see beams of light shining through the environment

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

What is a positve of using a spritesheet vs multiple sprites?

A

Saves memory

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

What Sprite Mode should a spritesheet have?

A

Multiple

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

The unity scene view is comprised of what?

A

Units

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

If making a pixel art game how many pixels per a unity unit do you want?

A

1

35
Q
A

MonoBehavior is an extended class that allows for our class to interact with Unity

36
Q
A

The start method is where you set up things in your class

37
Q
A

The update method is what happens on each frame before draw gets called

38
Q

What are the two static properties we should place on a pixel perfect camera?

What is the one non static property we should place on a pixel perfect camera?

A

public static float pixelsToUnits = 1f; //If pixel perfect

public static float scale = 1f;

public Vector2 nativeResolution = new Vector2(240, 160);

39
Q

What is the content of an Awake method for a pixel perfect camera?

A

var camera = GetComponent<camera>();</camera>

if(camera.orthographic){

scale = Screen.height/nativeResolution.y;

pixelsToUnits *= scale;

camera.orthographicSize = (Screen.height / 2.0f) / pixelsToUnits;

}

40
Q

What method do we need to create our camera?

A

void Awake(){

//code

}

41
Q

What does the Awake method do?

A

It’s called before Start method

42
Q

What is a Transform?

A

Every object in a scene has a Transform, it’s used to store and manipulate the position, rotation and scale of the object.

43
Q

What value must be changed on a background in order to create the illusion of a moving background?

A

The shaders offset value

44
Q

How do you create a Vector2 called speed with zero x and y?

A

public Vector2 speed = Vector2.zero;

45
Q

given “private Material material;” how would you store the components current material inside material?

A

material = GetComponent<renderer>().material;</renderer>

46
Q

How do you get the offset off of a material “material” and store it in a Vector2 “offset”?

A

offset = material.GetTextureOffset(“_MainTex”);

47
Q

What does deltaTime represent?

A

The difference in time between one frame rendering and the next frame rendering

48
Q

How do you get the deltaTime?

A

Time.deltaTime;

49
Q

Mesh Collider

A

Component used for Unity’s 3D physics engine

50
Q

Where is the 0,0 location on a given sprite?

A

At its pivot point

51
Q

What do you do if you want a sprites 0,0 point to be at the top left?

A

Go to the sprite and change Pivot to Top Left

52
Q

What is a Rigidbody 2D

A

Rigidbody 2D is a component that applies 2d physics to a GameObject

53
Q

How do you get rid of a GameObjects gravity?

A

Change its Rigidbody 2D’s Gravity Scale to 0.

54
Q

What is a Prefab?

A

A Prefab is a re-usable GameObject that we can configure.

55
Q

What is a Box Collider2D

A

Defines the bounds for interaction with other GameObjects.

56
Q

What is FixedUpdate() ?

A

FixedUpdate is a special kind of update reserved for making physics calculations, and only gets called a limited number of times per a frame which makes it more efficient for doing any of our physics calculations.

57
Q

What should you do If an object is jittery when moving across the screen?

A

Change the objects Rigidbody Interpolate to Interpolate.

58
Q

What is Interpolate?

A

Interpolate is a property in the Rigidbody 2D component that will get the preivous frames movement and apply it to the current frame to remove jitter.

59
Q

What is a Coroutine?

A

A Coroutine is a way to run a script independent of a normal loop, usually coupled with some sort of timer or wait so that when the coroutine gets called it waits for a certain amount of time before executing. Similar to functions but executes incrementally over time instead of waiting until it is finished.

60
Q

How do you pause and resume a coroutine?

A

Use the yield keyword.Often used like:yield return new WaitForSeconds(1)

61
Q

How do you delete GameObjects?

A

Destroy(GameObject)

62
Q

what does a rigidbody’s velocity tell us?

A

Which direction the rigidbody is heading

63
Q

Where would you find a GameObjects velocity?

A

Int he GameObjects rigidbody’s velocity property?

64
Q

How would you find a GameObjects velocity x?

A

private Rigidbody2D body2d;

void Awake()

{

body2d = GetComponent<rigidbody2d>();</rigidbody2d>

}

void Update()

{

var velocity = body2d.velocity.x;

}

65
Q

When does an item extend MonoBehavior?

A

When it is attached to a gameObject

66
Q

How is a static method called?

A

By typing the full name of its class and then a dot and then the name of the method.

67
Q

How do you deactive a gameObject?

A

gameObject.SetActive(false);

68
Q

What does setActive(false) do?

A

It allows us to deactive a gameObject so that it still exists in the hierarchy but it won’t be visible and it’s scripts won’t execute.

69
Q

What does setActive(true) do?

A

It reactivates a gameObject so that it is now visible again and will execute it’s attached scripts.

70
Q

Will Unity throw an error if you try to get a component that doesn’t exist from a gameObject?

A

No

71
Q

How would you check if a gameObject go is inactive?

A

if(go.gameObject.activeSelf != true)

72
Q

What is an interface?

A

A type of contract that insures that a class that uses it will always have the same type of public methods.

73
Q

How do you implement an interface IRecycle on a public class Obstacle that extends the class MonoBehaviour.

A

public class Obstacle : MonoBehaviour, IRecycle

74
Q

What do you need to do in order to be able to drag textures onto a component?

A

Lock the inspector

75
Q

How do you get a random element from an array sprites?

A

sprites[Random.Range(0, sprites.Length)];

76
Q

How do we set the size of a GameObject Obstacle’s collider given…

var renderer = GetComponent<spriterenderer>();</spriterenderer>

var collider = GetComponent<boxcollider2d>();</boxcollider2d>

A

collider.size = renderer.bounds.size;

77
Q

How do you get the y velocity of the current gameObject given the following?

private void Awake()
{
body2d = GetComponent();
}

private void FixedUpdate()
{
 //Code here
}
A

velY = body2d.velocity.y

78
Q

What is Any State in regards to the animator panel?

A

A way for us to transition from one state to another no matter where we come from.

79
Q

What are two ways to create new animations?

A
  1. Drag a selection of sprites into the scene
  2. Go to the Animation Pane, select the current animation dropdown, select “Create New Clip”
80
Q

What two components on a GameObject are necessary to display an animation?

A
81
Q

In the animation panel, what does “Samples” represent?

A

The Sample Rate which represents how many frames per second each frame of animation will render

82
Q

In the animation panel, what is the default Sample Rate?

A

60

83
Q

If an animation has a transition occur over a period of time how do you remove it?

A

Click on the transition in the animator panel, open up “Settings” dropdown, set “Transition Duration (s)” to 0

84
Q
A