Seems more reliable than the original method but not perfect
This commit is contained in:
@@ -38,15 +38,19 @@ func _physics_process(delta):
|
||||
func _on_body_entered(body: Node) -> void:
|
||||
|
||||
if !body.is_in_group("player"):
|
||||
print("BODY HIT - " + str(body))
|
||||
#Break Breakable Objects
|
||||
if body.is_in_group("breakable"):
|
||||
body.breaking(linear_velocity)
|
||||
|
||||
if body.is_in_group("switch"):
|
||||
body.hit()
|
||||
|
||||
|
||||
if ray.is_colliding():
|
||||
print("ray collision")
|
||||
else:
|
||||
print("no ray collision")
|
||||
|
||||
mesh.visible = false
|
||||
|
||||
if 1>2:#ray.is_colliding() and !ray.get_collider().is_in_group("player"):
|
||||
if ray.is_colliding() and !ray.get_collider().is_in_group("player"):
|
||||
#Bullet Hole Effect
|
||||
ray.get_collider().add_child(instance_bullethole)
|
||||
instance_bullethole.global_transform.origin = ray.get_collision_point()
|
||||
@@ -55,19 +59,13 @@ func _on_body_entered(body: Node) -> void:
|
||||
else:
|
||||
instance_bullethole.look_at(ray.get_collision_point() + ray.get_collision_normal())
|
||||
|
||||
#Break Breakable Objects
|
||||
if ray.get_collider().is_in_group("breakable"):
|
||||
var current_velocity = transform.basis * Vector3(0,0,-1 * bullet_force_mod)
|
||||
ray.get_collider().breaking(current_velocity)
|
||||
|
||||
#Hit Enemies
|
||||
if ray.get_collider().is_in_group("enemy_target"):
|
||||
hit_indicator.play()
|
||||
enemy_particles.emitting = true
|
||||
ray.get_collider().hit(bullet_damage)
|
||||
|
||||
|
||||
#Switch Switches
|
||||
if ray.get_collider().is_in_group("switch"):
|
||||
ray.get_collider().hit()
|
||||
|
||||
queue_free()
|
||||
|
||||
Reference in New Issue
Block a user