Kizspy | Question: 39
(Choose 1 answer)
Given the following C# code in Unity, what action is performed when the Space key is pressed (the lines of
code are in Update method)?
if (Input.GetKeyDown(KeyCode. Space))
{
Debug.Log("Jump");
else if (Input.GetKeyDown(KeyCode.LeftShift))
Debug.Log("Run");
else
Debug.Log("Idle");
A. Prints "Jump" when the Space key is pressed, "Run" when the LeftShift key is pressed, and "Idle" when
nothing is pressed.
B. Only prints "Jump" when the Space key is pressed and does nothing for other keys.
C. Prints "Idle" regardless of which key is pressed.
D. Prints "Jump" when the Space key is pressed and "Idle" in all other cases.