0
0
Unityframework~10 mins

Why input drives player interaction in Unity - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to read horizontal input from the player.

Unity
float move = Input.GetAxis([1]);
Drag options to blanks, or click blank then click option'
A"Vertical"
B"Fire1"
C"Jump"
D"Horizontal"
Attempts:
3 left
💡 Hint
Common Mistakes
Using "Vertical" instead of "Horizontal" will read up-down input.
Using "Jump" or "Fire1" reads button presses, not axis movement.
2fill in blank
medium

Complete the code to move the player horizontally based on input.

Unity
transform.Translate(move * [1] * Time.deltaTime, 0, 0);
Drag options to blanks, or click blank then click option'
Agravity
Bspeed
CjumpForce
Dhealth
Attempts:
3 left
💡 Hint
Common Mistakes
Using gravity or jumpForce will not move the player horizontally.
Using health is unrelated to movement.
3fill in blank
hard

Fix the error in the code to detect when the player presses the jump button.

Unity
if (Input.GetButtonDown([1])) {
    Jump();
}
Drag options to blanks, or click blank then click option'
A"Fire1"
B"Horizontal"
C"Jump"
D"Vertical"
Attempts:
3 left
💡 Hint
Common Mistakes
Using "Fire1" detects firing, not jumping.
Using "Horizontal" or "Vertical" reads axis movement, not button presses.
4fill in blank
hard

Fill both blanks to create a dictionary that maps input names to their current values.

Unity
var inputValues = new Dictionary<string, float> {
    {"Horizontal", [1],
    {"Vertical", [2]
};
Drag options to blanks, or click blank then click option'
AInput.GetAxis("Horizontal")
BInput.GetButtonDown("Jump")
CInput.GetAxis("Vertical")
DInput.GetButton("Fire1")
Attempts:
3 left
💡 Hint
Common Mistakes
Using button methods like GetButtonDown or GetButton returns bool, not float.
Mixing axis and button input methods causes type errors.
5fill in blank
hard

Fill all three blanks to check if the player pressed the fire button and move the player accordingly.

Unity
if (Input.GetButtonDown([1])) {
    Shoot();
}

float move = Input.GetAxis([2]);
transform.Translate(move * [3] * Time.deltaTime, 0, 0);
Drag options to blanks, or click blank then click option'
A"Fire1"
B"Horizontal"
Cspeed
D"Jump"
Attempts:
3 left
💡 Hint
Common Mistakes
Using "Jump" instead of "Fire1" for firing input.
Using button input names for axis input causes errors.
Forgetting to multiply by speed causes no movement.