Layers And Tags Flashcards

1
Q

Uses of layers

A

You can use layers to optimize your project and work flow. Common uses of layers include
Layer based rendering and layer based collision

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

Camera and culling mask with layers

A

You can render only the objects in a particular layer, or selection of layers, if you use the Cameras culling mask. To change the culling mask, select the camera you want to use, and select the Culling Mask dropdown in the inspector window.
If you clear the checkbox of a layer, it doesn’t render in the scene.

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

Ui elements and screen space canvas children are exceptions to the culling mask check box, which prevents rendering, and render regardless

A

True

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

Ray cast with Layers

A

You can use layers to specify which GameObjects that a ray cast can intersect with.
To make a ray cast ignore a GameObject, you can assign it to the Ignore Raycast layer, or pass a LayerMask to the Ray cast API call

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

Physics.Raycast function

A

Physics.Raycast function uses a bit ask, and each but determines if a layer is ignored by rays or not. If all bits in the LayerMask are on, the Ray collides against all collides. If the LayerMask =0, there are no collisions

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

Example of a ray on layer 8

A
Int layerMask = 1 << 8;
//Does the Ray intersect any objects which are in layer 8?
If (Physics.Raycast (transform.position, Verctor3.forward, Mathf.Infinity, layerMask))
{Debug.Log("The ray hit the player")}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Ray cast with layers

A

You can do the inverse, so that the Ray collides with all layers except layer 8
If you don’t pass a LayerMask to the Raycast function, it still ignores colliders that use the IgnoreRaycast layer

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

What are tags in unity

A

Tags and layers must be declared in the tags and layers manager before using them
Tags are used to help identify game objects in unity

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

Tags in unity

A reference word that can be assigned to a GameObject

A

You can use the CompareTag(“ “) component to search for and affect on objects with the specific tags on them

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

You should not set a tag from the Awake or OnValidate method

A
You can set a tag to a GameObject by
Void Start()
{GameObject.tag = "Player" ; }
How well did you know this?
1
Not at all
2
3
4
5
Perfectly