0
0
Unityframework~10 mins

Mouse input (GetMouseButton, position) 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 check if the left mouse button is pressed.

Unity
if (Input.[1](0)) {
    Debug.Log("Left mouse button pressed");
}
Drag options to blanks, or click blank then click option'
AGetMouseButton
BGetMouseButtonDown
CGetMouseButtonUp
DIsMouseButton
Attempts:
3 left
💡 Hint
Common Mistakes
Using GetMouseButtonDown instead of GetMouseButton
Using wrong button index
2fill in blank
medium

Complete the code to get the current mouse position on the screen.

Unity
Vector3 mousePos = Input.[1];
Drag options to blanks, or click blank then click option'
AmousePosition
BGetMousePosition
CmousePos
DMousePosition
Attempts:
3 left
💡 Hint
Common Mistakes
Trying to call a method instead of using the property
Using incorrect capitalization
3fill in blank
hard

Fix the error in the code to detect right mouse button release.

Unity
if (Input.[1](1)) {
    Debug.Log("Right mouse button released");
}
Drag options to blanks, or click blank then click option'
AGetMouseButton
BGetMouseButtonUp
CIsMouseButtonUp
DGetMouseButtonDown
Attempts:
3 left
💡 Hint
Common Mistakes
Using GetMouseButtonDown instead of GetMouseButtonUp
Using wrong button index
4fill in blank
hard

Fill both blanks to check if the middle mouse button is held and get its position.

Unity
if (Input.[1](2)) {
    Vector3 pos = Input.[2];
    Debug.Log(pos);
}
Drag options to blanks, or click blank then click option'
AGetMouseButton
BGetMouseButtonDown
CmousePosition
DGetMouseButtonUp
Attempts:
3 left
💡 Hint
Common Mistakes
Using GetMouseButtonDown instead of GetMouseButton for holding
Using wrong property name for position
5fill in blank
hard

Fill all three blanks to detect left click, get position, and print X coordinate.

Unity
if (Input.[1](0)) {
    Vector3 pos = Input.[2];
    Debug.Log(pos.[3]);
}
Drag options to blanks, or click blank then click option'
AGetMouseButtonDown
BmousePosition
Cx
DGetMouseButtonUp
Attempts:
3 left
💡 Hint
Common Mistakes
Using GetMouseButton instead of GetMouseButtonDown for click
Trying to print the whole position instead of just x