0 votes

Hello everyone!
I got 2 coordinates from my mouse using get_viewport().get_mouse_position()
Now I want to move one of my kinematic objects to these coordinates.
I think I need just a way to move my kinematic using coordinates cause my object just move weird but see yourself:

extends KinematicBody

var speed = 50
var direction = Vector3()

func _physics_process(delta):
    direction = Vector3(0, 0, 0)
    if Input.is_action_just_pressed("Mouse"):
        direction.x = get_viewport().get_mouse_position().x
        direction.z = 1
        direction.y = get_viewport().get_mouse_position().y
        direction = direction.normalized()
        direction - direction * speed * delta
        move_and_slide(direction, Vector3(0, 1, 0))
in Engine by (12 points)

1 Answer

0 votes

You may want to check out the docs they have a click and move tutorial.

by (18 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 Frequently asked questions and 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.