0
0
Unityframework~5 mins

Mouse input (GetMouseButton, position) in Unity - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does Input.GetMouseButton(0) check in Unity?
It checks if the left mouse button is currently being pressed down.
Click to reveal answer
beginner
How do you get the current position of the mouse cursor in Unity?
Use Input.mousePosition, which returns the mouse position in pixel coordinates relative to the bottom-left corner of the screen.
Click to reveal answer
intermediate
What is the difference between Input.GetMouseButtonDown(0) and Input.GetMouseButton(0)?
GetMouseButtonDown(0) returns true only during the frame the left mouse button is pressed. GetMouseButton(0) returns true as long as the button is held down.
Click to reveal answer
beginner
If you want to detect a right mouse button click, which parameter do you use with GetMouseButton?
Use Input.GetMouseButton(1) to detect the right mouse button.
Click to reveal answer
intermediate
How can you convert Input.mousePosition to a world position in Unity?
Use Camera.main.ScreenToWorldPoint(Input.mousePosition) to convert the screen pixel position of the mouse to a position in the game world.
Click to reveal answer
What does Input.GetMouseButton(0) return when the left mouse button is not pressed?
ATrue
BNull
CFalse
DThrows an error
Which method returns true only on the exact frame the mouse button is pressed?
AInput.GetMouseButtonDown(0)
BInput.GetMouseButtonUp(0)
CInput.GetMouseButton(0)
DInput.mousePosition
What type of value does Input.mousePosition return?
AVector2 with world coordinates
BInteger
CBoolean
DVector3 with screen pixel coordinates
How do you detect a right mouse button press in Unity?
AInput.GetMouseButton(0)
BInput.GetMouseButton(1)
CInput.GetMouseButton(2)
DInput.GetMouseButtonDown(0)
Which function converts mouse screen position to world position?
ACamera.main.ScreenToWorldPoint()
BInput.GetMouseButton()
CInput.mousePosition.ToWorld()
DCamera.main.WorldToScreenPoint()
Explain how to detect when the left mouse button is pressed and get the mouse position in Unity.
Think about checking the button press and reading the position separately.
You got /3 concepts.
    Describe how to convert the mouse position from screen space to world space in Unity.
    Remember the camera translates screen pixels to game world.
    You got /3 concepts.