tweaked bullet and pick up method
This commit is contained in:
@@ -34,38 +34,35 @@ func _physics_process(delta):
|
||||
|
||||
if distance_from_player.length() > 1.5:
|
||||
visible = true
|
||||
|
||||
|
||||
func _on_body_entered(body: Node) -> void:
|
||||
|
||||
if !body.is_in_group("player") and bullet_active:
|
||||
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() 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()
|
||||
if (abs(ray.get_collision_normal().y) > 0.99):
|
||||
instance_bullethole.look_at(ray.get_collision_point() + ray.get_collision_normal(), Vector3(0,0,1))
|
||||
else:
|
||||
instance_bullethole.look_at(ray.get_collision_point() + ray.get_collision_normal())
|
||||
|
||||
#Hit Enemies
|
||||
if ray.get_collider().is_in_group("enemy_target"):
|
||||
hit_indicator.play()
|
||||
enemy_particles.emitting = true
|
||||
SignalBus.emit_signal("enemy_hit")
|
||||
ray.get_collider().hit(bullet_damage)
|
||||
if ray.is_colliding() and !ray.get_collider().is_in_group("player"):
|
||||
|
||||
mesh.visible = false
|
||||
bullet_active = false
|
||||
particles.emitting = true
|
||||
await get_tree().create_timer(1).timeout
|
||||
ray.enabled = false
|
||||
|
||||
#bullethole effect
|
||||
ray.get_collider().add_child(instance_bullethole)
|
||||
instance_bullethole.global_transform.origin = ray.get_collision_point()
|
||||
if (abs(ray.get_collision_normal().y) > 0.99):
|
||||
instance_bullethole.look_at(ray.get_collision_point() + ray.get_collision_normal(), Vector3(0,0,1))
|
||||
else:
|
||||
instance_bullethole.look_at(ray.get_collision_point() + ray.get_collision_normal())
|
||||
|
||||
if ray.get_collider().is_in_group("switch"):
|
||||
ray.get_collider().hit()
|
||||
|
||||
#move rigidbodies
|
||||
if ray.get_collider().is_in_group("scene_rigidbody"):
|
||||
ray.get_collider().linear_velocity += transform.basis * Vector3(0,0,-1 * bullet_force_mod)
|
||||
|
||||
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)
|
||||
|
||||
|
||||
if ray.get_collider().is_in_group("enemy_target"):
|
||||
hit_indicator.play()
|
||||
enemy_particles.emitting = true
|
||||
ray.get_collider().hit(bullet_damage)
|
||||
await get_tree().create_timer(1.0).timeout
|
||||
queue_free()
|
||||
|
||||
Reference in New Issue
Block a user