0 votes
extends KinematicBody2D
func _ready():
    set_physics_process(true)    
func _physics_process(delta):
    var x = get_viewport().get_mouse_position().x
    var y = get_viewport().get_mouse_position().y
    set_position(Vector2(x,y))

My code for the object looks like that, but instead of being beneath the cursor it stands off like this:enter image description here
(already tried global mouse pos, and I don't think it has to do with the object's speed)

in Engine by (20 points)

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 "setphysicsprocess(true)"

1 Answer

0 votes

You can just use position = get_global_mouse_pos()

by (68 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.

Categories