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))
asked Jul 23, 2018 in Engine by Josqu (12 points)

1 Answer

0 votes

You may want to check out the docs they have a click and move tutorial.
https://docs.godotengine.org/en/3.2/tutorials/2d/2d_movement.html

answered Apr 24 by Jakeeee (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 How to use this Q&A? before posting your first questions.