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()

A

Collider

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
Q

What is returned by ScreenPointToRay?

A

A Ray.

26
Q

What are the arguments to ScreenPointToRay?

A

Screen space coordinates

27
Q

Which component of the Ray object gives us the vector along which the Ray points?

A

.direction

28
Q

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?

A

Debug.DrawRay( )

29
Q

How do we get the mouse coordinates in screen space?

A

Input.mousePosition

30
Q

When combining two rotations into a new rotation, is the order important?

A

Yes, always.

31
Q

Quaternion.Euler() builds a rotation out of 3 seperate rotations about x, y and z axes. Which order are these performed in?

A

z, x and y

32
Q

Quaternion.LookRotation() is a…

A

Method on the class Quaternion.

33
Q

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?

A

Quaternion rotation = Quaternion.AngleAxis (90, a) ;

34
Q

How is a Quaternion internally stored?

A

Using x, y, z and w variables.