This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

It's 3D and top down...45degree top down with 8 direction movement. When I press left, the player moves left but the mesh should also look left and this, should happen smoothly, for all 8 directions.

It .........kinda? works what I have but it is very buggy and only works if the the starting rotation is 180 degree on Y axis. I search for a more reliable and less buggy version but couldn't come up with one.

it's this line particular:

    var new_transform = $dachs2.transform.looking_at(direction, Vector3.UP)
    $dachs2.transform  = $dachs2.transform.interpolate_with
   (new_transform, speed * delta)

and the rest of it:

extends KinematicBody

export var speed : float = 10
export var friction : float = .18
var motion = Vector3.ZERO
var velocity : Vector3
export var gravity = Vector3.DOWN * 50
var vel = Vector3()

func _ready():
var direction = Vector3.ZERO

func _physics_process(delta):

velocity += gravity * delta


get_node("dachs2/AnimationPlayer").play("Idle")

var direction = Vector3.ZERO

if Input.is_action_pressed("right"):
    direction.x += 1
if Input.is_action_pressed("left"):
    direction.x -= 1
if Input.is_action_pressed("down"):

    direction.z += 1
if Input.is_action_pressed("up"):
    direction.z -= 1

if direction != Vector3.ZERO:
    direction = direction.normalized()

var new_transform = $dachs2.transform.looking_at(direction, Vector3.UP)
$dachs2.transform  = $dachs2.transform.interpolate_with(new_transform, speed * delta)

velocity.x = direction.x * speed
velocity.z = direction.z * speed

velocity = move_and_slide(velocity, Vector3.UP)

print(direction)
Godot version v3.4.1.rc1.official [7b0801c7f]
in Engine by (173 points)

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 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 [email protected] with your username.