look_at rotates KinematicBody (3D) -90 degrees to where it should

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

After searching around, I think that my KinematicBody is not facing -Z but I have no clue how to fix this.

The KinematicBody’s “Transform” is all zeros for Translation and Rotation Degrees. My code follows:

const RAY_LENGTH = 1000

onready var camera = $Camera  # Spatial Camera

func _process(delta):    
    if Input.is_action_just_pressed("movement"):  # Right mouse click
        var mouse_position = get_viewport().get_mouse_position()
        var ray_start = camera.project_ray_origin(mouse_position)
        var ray_end = ray_start + (camera.project_ray_normal(mouse_position) * RAY_LENGTH)
        var space_state = get_world().direct_space_state
        var result = space_state.intersect_ray(ray_start, ray_end, [], ENVIRONMENT)
        if result:
            var target_position = result.position
            look_at(target_position, Vector3.UP)

Edit: I tried changing the KinematicBody’s Rotation Degrees to 90 but it did not solve the issue.

:bust_in_silhouette: Reply From: umma

your question isn’t clear, but try rotating your mesh instances or childrem of the kinematic body to 180,-180,90 or -90.

You are correct, instead of rotating my kinematic body, I had to rotate its children. Thank you!

flaae | 2022-01-29 22:13