diff --git a/Game/Assets/Weapons/Weapon.gd b/Game/Assets/Weapons/Weapon.gd index ef73b77..4ba76d7 100644 --- a/Game/Assets/Weapons/Weapon.gd +++ b/Game/Assets/Weapons/Weapon.gd @@ -78,17 +78,16 @@ var spread = spread_min var x := Vector3.ZERO var A = from var B = to - - var AB = B - A var C = get_tree().get_root().get_camera_3d().global_transform.origin - if A.dot(C) < 0 and B.dot(C) < 0: + var d0 = (B - A).dot(A - C) + var d1 = (B - A).dot(B - C) + + if d0 < 0 and d1 < 0: print("Firing away from the camera") - elif A.dot(C) > 0 and B.dot(C) > 0: + elif d0 > 0 and d1 > 0: print("Bullet hit before passing by") else: - var d0 - var d1 var X = d0/(d0-d1) var flyby = flyby_sound.instantiate() get_tree().root.add_child(flyby)