0
0
Unityframework~10 mins

Input axis for smooth movement in Unity - Interactive Code Practice

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

Complete the code to get horizontal input for smooth movement.

Unity
float horizontal = Input.[1]("Horizontal");
Drag options to blanks, or click blank then click option'
AGetButtonDown
BGetAxis
CGetKeyDown
DGetButtonUp
Attempts:
3 left
💡 Hint
Common Mistakes
Using GetButtonDown instead of GetAxis causes no smooth movement.
Using GetKeyDown returns true only on key press, not continuous input.
2fill in blank
medium

Complete the code to move the player smoothly on the x-axis.

Unity
transform.Translate(horizontal * speed * Time.[1]);
Drag options to blanks, or click blank then click option'
AdeltaTime
BtimeScale
CfixedDeltaTime
DunscaledDeltaTime
Attempts:
3 left
💡 Hint
Common Mistakes
Using fixedDeltaTime in Update can cause inconsistent movement.
Using timeScale or unscaledDeltaTime is not suitable for normal movement timing.
3fill in blank
hard

Fix the error in the code to read vertical input smoothly.

Unity
float vertical = Input.[1]("Vertical");
Drag options to blanks, or click blank then click option'
AGetButton
BGetAxisRaw
CGetAxis
DGetKey
Attempts:
3 left
💡 Hint
Common Mistakes
Using GetAxisRaw causes jerky movement instead of smooth.
Using GetButton or GetKey returns boolean, not float values.
4fill in blank
hard

Fill both blanks to create a dictionary of axis values for movement.

Unity
var movement = new Dictionary<string, float> { {"horizontal", Input.[1]("Horizontal")}, {"vertical", Input.[2]("Vertical")} };
Drag options to blanks, or click blank then click option'
AGetAxis
BGetButtonDown
CGetAxisRaw
DGetKeyDown
Attempts:
3 left
💡 Hint
Common Mistakes
Using GetButtonDown or GetKeyDown returns booleans, not floats.
Using the same method for both axes may not fit all movement needs.
5fill in blank
hard

Fill all three blanks to create a movement vector and apply it smoothly.

Unity
Vector3 move = new Vector3(Input.[1]("Horizontal"), 0, Input.[2]("Vertical"));
transform.Translate(move * speed * Time.[3]);
Drag options to blanks, or click blank then click option'
AGetAxis
BGetAxisRaw
CdeltaTime
DGetButton
Attempts:
3 left
💡 Hint
Common Mistakes
Using GetButton returns bool, not float values.
Not using deltaTime causes movement to depend on frame rate.