tutorials/inputs/mouse_and_input_coordinates #25
Replies: 4 comments 4 replies
-
A working example that only fires once when you click a button, and shows you how to check the states of the buttons and mouse wheel : func _input(event):
if event is InputEventMouseButton and event.pressed:
if event.button_index == MOUSE_BUTTON_LEFT :
print("Left mouse button")
if event.button_index == MOUSE_BUTTON_WHEEL_UP :
print("Scroll wheel up")
if event.button_index == MOUSE_BUTTON_WHEEL_DOWN:
print("Scroll wheel down") |
Beta Was this translation helpful? Give feedback.
-
Does someone have a working example of mouse position for Multiplayer cause I can’t get it working! I have tried using get_viewport().get_mouse_position() but it’s way off!! 😅 |
Beta Was this translation helpful? Give feedback.
-
In case you're trying to convert mouse position to position in your 2D world with a camera, this might be useful: func _input_event(viewport: Viewport, event: InputEvent, shape_idx: int) -> void:
if event is InputEventMouseButton and event.pressed:
var camera = viewport.get_camera_2d()
click.emit((event.position / camera.zoom) + camera.offset) |
Beta Was this translation helpful? Give feedback.
-
There is a function on I actually think there should be a function,
just so folks would find it when they're looking for options with |
Beta Was this translation helpful? Give feedback.
-
tutorials/inputs/mouse_and_input_coordinates
About: The reason for this small tutorial is to clear up many common mistakes about input coordinates, obtaining mouse position and screen resolution, etc. Hardware display coordinates: Using hardw...
https://docs.godotengine.org/en/latest/tutorials/inputs/mouse_and_input_coordinates.html
Beta Was this translation helpful? Give feedback.
All reactions