2D zenital View car movement

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By ManiCus

it’s hard to explain, imagine a car from a zenital view in 2d, the car looks where the mouse is, when you press the indicated key I want the car to move in the direction where the mouse is, Do you understand?

What do you mean by “zenital”? A top-down-view? And which part are you struggling with? Getting the mouse position? Having the car face or move there? Detecting a key press? Also: Do you want the car to move instantly (“teleport”) or over time? Should it stop once the player releases the key? Does it have a fixed goal (the mouse position when the key was pressed) or update its target if the player moves the mouse during the movement?

njamster | 2020-08-08 21:34

Don’t worry hehe finally I figured out by myself:

func _proces(delta):
position()

func position():
var pos = get_global_mouse_position() - position
if Input.is_action_pressed(“movement”):
move_and_slide(pos)

ManiCus | 2020-08-08 21:35