Two way player movement.

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

I’m new to GDScript, and I want to know if there is any way to move the player locally instead of globally.

Now, this might be not the thing that I want to do,
Let me explain what I want to achieve;
I can turn my player right or left (you can imagine this as a vehicle) and when I move forward the player moves forward. Now the issue is it does not move in the direction that it’s looking towards!

How can I do that?

this ?
look in the direction it’s moving

var velo = Vector3.ZERO

if velo != Vector3.ZERO:
	look_at(translation - velo,Vector3.UP)

and
move in the direction it is looking

func _process(delta):
	var dir = Vector3.ZERO
	if Input.is_action_pressed("ui_up"):
		dir = transform.basis.z * 50 

or
https://www.youtube.com/watch?v=UpF7wm0186Q

ramazan | 2022-09-24 21:37