Godot Version
3.5.2 stable
Question
I’m learning for myself and I’m trying to make a node point to the direction of the mouse, I just wanted to test how it would work using look_at(get_global_mouse_position) but although the object moves with the mouse, it points to an offset position.
The object I’m trying to move is a Node2D with 2 sprites (and an AnimationPlayer to make a recoil animation):
Cannon
|_CannonMouth
|_CannonBody
|_AnimationPlayer
This scene is instanced in another scence called CannonBase with just a Sprite.
extends Node2D
onready var animacion = $AnimationPlayer
func _physics_process(delta):
var posicion = get_global_mouse_position()
look_at(posicion)
if Input.is_action_pressed("Disparar"):
animacion.play("Disparo")