43 lines
1.3 KiB
GDScript
43 lines
1.3 KiB
GDScript
extends RayCast3D
|
|
|
|
@onready var hit_indicator: AudioStreamPlayer = $"../../../../Audio/HitIndicator"
|
|
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
func _ready() -> void:
|
|
pass # Replace with function body.
|
|
|
|
|
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
func _process(delta: float) -> void:
|
|
pass
|
|
|
|
func hitscan_fire(bullet_damage,bullet_force_mod,bullethole):
|
|
|
|
if is_colliding():
|
|
|
|
#bullethole effect
|
|
var instance_bullethole = bullethole.instantiate()
|
|
get_collider().add_child(instance_bullethole)
|
|
instance_bullethole.global_transform.origin = get_collision_point()
|
|
if (abs(get_collision_normal().y) > 0.99):
|
|
instance_bullethole.look_at(get_collision_point() + get_collision_normal(), Vector3(0,0,1))
|
|
else:
|
|
instance_bullethole.look_at(get_collision_point() + get_collision_normal())
|
|
|
|
#move rigidbodies
|
|
if get_collider().is_in_group("scene_rigidbody"):
|
|
get_collider().linear_velocity += rotation * Vector3(0,0,-bullet_force_mod)
|
|
|
|
if get_collider().is_in_group("breakable"):
|
|
get_collider().breaking( Vector3(0,0,-bullet_force_mod))
|
|
|
|
|
|
if get_collider().is_in_group("enemy_target"):
|
|
emit_signal("enemy_hit")
|
|
get_collider().hit(bullet_damage)
|
|
|
|
if get_collider().is_in_group("switch"):
|
|
get_collider().hit()
|
|
|