Im adding ne projectiles to my game, but found a problem. With larger projecties, we noticed that the are not properly rotated towards the moving direction. That was not visible when using a small capsule, but if we use a larger particle system with a trail and a head, you see how the fireball moves with head to a side or any other direction.
To instantiate the projectile I use a node in the weapon scene and this code:
var owner_forward = owner.get_actor().global_transform.basis.z #forward dir of plyer model
var forward
if item_mesh!=null:
forward = item_mesh.global_transform.basis.z #fwd dir of weapon model
else:
forward = owner_forward #if weapon has no model, we use player model
trace.global_transform.origin = item_mesh.find_node("flash").global_transform.origin + owner_forward*1.5
trace.transform.basis.z = item_mesh.find_node("flash").global_transform.basis.z
trace.dir = Vector2(owner_forward.x, owner_forward.z) #movement direction of bullet
How can I make my projectile move in the direction the player is facing and also rotate to cpoint tat direction?