How can i get my object to stand directly beneath my mouse cursor?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By mrmtonio
extends KinematicBody2D
func _ready():
func _physics_process(delta):
    var x = get_viewport().get_mouse_position().x
    var y = get_viewport().get_mouse_position().y

My code for the object looks like that, but instead of being beneath the cursor it stands off like this:

(already tried global mouse pos, and I don’t think it has to do with the object’s speed)

I’ll see what I can do when I get back from work, but if you’re not using Godot 2.1.x, you don’t need “set_physics_process(true)”

HarryCourt | 2018-07-25 23:57

:bust_in_silhouette: Reply From: Lucas Coelho

You can just use position = get_global_mouse_pos()