Hello, I am new to Godot and I would like a question answered, my character is static and I want his weapon to point in the direction of my mouse at all times, but I am having problems since I saw the documentation and I understand that you can use these options:
1-var mouse_pos = get_global_mouse_pos()
2-get_viewport().get_global_mouse_position()
The first option tells me that it is not found, the second does “work” but it does nothing.
This is the small code that I have as proof, the weapon rotates from a 2d node called Pivot:
extend Node
func _ready():
pass # Replace with function body.
func _physics_process(delta):
look_at_mouse
func look_at_mouse():
var mouse_pos = get_viewport().get_global_mouse_position()
get_node(“Pivot”).look_at(mouse_pos)
In the docs under (most) node descriptions there are a list of inherits/inherited by. A node can use values, functions, etc… from nodes that it inherits from.