I am trying to make a NPC (KinematicBody (3D) firing a bullet to the direction the NPC is lookingat.
I successfully get my bullets spawning in front of the NPC, but instead of moving along the facing direction, they are always spawing and moving 90° from the lookat direction of the npc.
This is my code of the NPC setting look_at to the players position
(that part works fine so far)
func _process(delta):
var LookAtPosition = get_node("../Player").get_translation()
look_at(LookAtPosition, UP)
var follow_vect = (LookAtPosition-get_translation()).normalized()*delta*speed
move_and_slide(follow_vect)
fall()
shoot(delta)
My shoot Function is now instancing the bullet scene (KinematicBody Node)
and I set the bullets values to the current NPCs Position & Rotation_Degree
func shoot(delta):
if fire_delay < 0:
var shot = bullet_scene.instance()
shot.global_transform.origin = transform.origin
shot.rotation_degrees = rotation_degrees
get_tree().root.add_child(shot)
fire_delay = max_fire_delay
else:
fire_delay -= 1.0 * delta
In my Bullet Scene I do that:
func _process(delta):
if ttl < 0:
queue_free()
else:
ttl -= delta
move_and_slide(get_global_transform().basis.x * speed)
As shown on the screen below, the bullets are not spawning and moving on the look_at angle, but 90 degress from the side of the npc.

What's wrong here? I'm importing my objects from blender. Is there a certain rotation to be done to define which part of the object is the front, left and right? Is there a better way to simply say: take the look_at direction as a vector and let another kinematicbody move along that vector?