0 votes

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?

in Projects by (95 points)

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?

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

func _proces(delta):
position()

func position():
var pos = getglobalmouseposition() - position
if Input.is
actionpressed("movement"):
move
and_slide(pos)

Please log in or register to answer this question.

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