i'm making a third person shooter. i'm sending projectile bullets from a raycast on the gun scene. when the player is facing roughly -z, everything seems to behave how it should. but as i turn more towards the other direction, the direction of the bullets is flipped vertically. when i'm facing +z, if i aim 30deg down, the bullet will shoot 30deg up, and vice versa. if i'm facing +x or -x, the bullet will just have a flat trajectory and ignore my vertical angle.
the weirdest part to me is that no matter what, the model for the bullet is always pointed in the right direction. i just want to make it move in that direction.
the behavior i'm describing is only after applying a bandaid solution of reversing several axes. if i don't do that, it's weirder and hard to describe.
shooting code:
if Input.is_action_just_pressed("fire"):
bullet_instance = bullet.instantiate()
bullet_instance.position = gun_barrel.global_position
bullet_instance.transform.basis = gun_barrel.global_transform.basis
get_tree().root.add_child(bullet_instance)```
bullet code:
```func _ready():
gravity_scale = 0.25
apply_central_impulse(Vector3(0, 0, -SPEED) * transform.basis * Vector3(-1, -1, 1))```
the last `* Vector3` is the bandaid i was talking about, it helped a lot but there's still this one weird issue. the first -1 makes it go in the right direction horizontally. before that, it would go as far left as i aimed right, so it went straight if i was aiming +z or -z, but if i turned 90deg in either direction, the bullet would go directly towards me. the second -1 just reversed the current issue, it made it so the bullets would be flipped vertically when i'm aiming -z, instead of when i'm aiming +z.
i'm wondering if there's some simple math i can do to just apply another bandaid? it feels like it's really close to working. but i'd also like to know if anyone understands the root cause of this.
thanks