Godot: mouse の座標を取得する
Godot Engineでマウスの座標を取得する方法
Godot 4.0 rc1 で確認
公式Doc: https://docs.godotengine.org/en/latest/tutorials/inputs/mouse_and_input_coordinates.html
いくつか方法がある
InputEventMouse の position から取得
code:gd
func _input(event):
if event is InputEventMouseButton:
print("Mouse Click/Unclick at: ", event.position)
viewport の get_mouse_position()で取得
get_viewport().get_mouse_position()
CanvasItem の get_global_mouse_position() で取得
get_global_mouse_position()
Returns the mouse's position in the CanvasLayer that this CanvasItem is in using the coordinate system of the CanvasLayer.