Fix the aiming and bullet creation

This commit is contained in:
2025-02-01 18:03:00 +01:00
parent 33f1d57a50
commit bd91818682
19 changed files with 334 additions and 8089 deletions

View File

@ -287,18 +287,6 @@ func _get_camera_collision():
else:
return ray_end
func _hit_scan_collision(collision_point):
var viewport = get_viewport().size
var ray_origin = first_view_camera.project_ray_origin(viewport / 2)
var ray_end = ray_origin + first_view_camera.project_ray_normal(viewport / 2 * 100)
var new_intersection = PhysicsRayQueryParameters3D.create(ray_origin, ray_end)
var bullet_collision = get_world_3d().direct_space_state.intersect_ray(new_intersection)
if bullet_collision:
_hit_scan_damage(bullet_collision.collider)
func _hit_scan_damage(Collider):
#if Collider.is_in_group("target") and Collider.has_method("take_damage"):
func take_damage(dam: int):
var new_health = health - dam
set_health(new_health)