Unity 3D Programming Flashcards

1
Q

From which menu can you create a new C# script?

A

Assets

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

Match the type to the expression. 1. float 2. float or int 3. int 4. other A. 1 B. int someInt; C. “Some text” D. 1.0f

A

1D, 2A, 3B, 4C

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

What type is someVariable? float someVariable = 2;

A

float

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

What is the result type of the following operation? 2 + 2

A

int

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

What is the type of someResult ? float someFloat = 3; int someInt = 3; ??? someResult = someFloat + someInt;

A

float

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

Which is the correct suffix for floating point numbers?

A

f

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

Why would you choose to wrap some functionality into a method?

A

To deal with concepts at a higher level.

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

What is the return type of this function declaration? int DoSomething (string aValue) { }

A

int

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

What types of variable does this take? float AnotherMethod(string foo, int bar) { }

A

string and int

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

What type does this method return? [omitted] SomeMethod () { return 2.0f + 1.0f; }

A

float

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

What in the following would cause an error in Visual Studio? 1. float Square (float numberToSquare) { 2.float square = numberToSquare * numberToSquare * numberToSquare; 3. }

A

Nothing returned from the method.

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

What is the correct way to create a 3D vector?

A

new Vector3 (1.0f, 1.0f, 1.0f)

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

Which of the following is a valid operation on vectors (assume variables a and b contain Vector3)?

A

a.magnitude

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

In the following lines of code, why do we use a dot? Vector3 a = new Vector3(1, 2, 3); float myX = a.x;

A

To access the contents x of the a variable

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

What data is a Vector3 made up of?

A

3 floats

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

What is an example of an object?`

A

A component of a GameObject

17
Q

Which of the following lines of code correctly gets a render component?

A

Renderer r = GetComponent( );

18
Q

What type is returned from the following line of code? GetComponent()

19
Q

GetComponent is a function used to find components of a certain type. Where will it search for components?

A

On the current GameObject.

20
Q

In which method should you do work relating to Physics?

A

FixedUpdate( )

21
Q

Order the following based on order of execution: A. Start() B. Update() C. FixedUpdate() D. LateUpdate()

A

1A, 2C, 3B, 4D

22
Q

Which of the following lines of code adds a force to a GameObject?

A

Rigidbody rb = GetComponent( ); rb.AddForce(new Vector3(0, 0, force));

23
Q

What is the correct definition of FixedUpdate?

A

void FixedUpdate( ) { }

24
Q

What is the time between FixedUpdate calls?

A

Fixed but configurable

25
What is returned by ScreenPointToRay?
A Ray.
26
What are the arguments to ScreenPointToRay?
Screen space coordinates
27
Which component of the Ray object gives us the vector along which the Ray points?
.direction
28
Which of the following functions would be best suited to helping debug a Ray that doesn't seem to be pointing in the correct direction?
Debug.DrawRay( )
29
How do we get the mouse coordinates in screen space?
Input.mousePosition
30
When combining two rotations into a new rotation, is the order important?
Yes, always.
31
Quaternion.Euler() builds a rotation out of 3 seperate rotations about x, y and z axes. Which order are these performed in?
z, x and y
32
Quaternion.LookRotation() is a...
Method on the class Quaternion.
33
Suppose I have a Vector3 which defines by rotation called a. Supposing I want to rotate 90 degrees around this axis, how would I construct a Quaternion to do this?
Quaternion rotation = Quaternion.AngleAxis (90, a) ;
34
How is a Quaternion internally stored?
Using x, y, z and w variables.