this script used to work in godot3
the visibility notifier when camera exited doesnt seem to do anything anymore
i probably need another func
extends RigidDynamicBody3D
@export var shellSounds : Array[AudioStreamSample]
@export var myAudioStream_path: NodePath
#@export var shellmesh_path: NodePath
#@onready var shellmesh = get_node(shellmesh_path)
@onready var myAudio = get_node(myAudioStream_path)
var random = RandomNumberGenerator.new()
func _ready():
add_to_group("ignore")
random.randomize()
#this doesnt work anymore in godot4
func _on_VisibilityNotifier_camera_exited(_camera):
self.queue_free()
func _on_pistolshell_body_entered(_body):
#shellmesh.set_layer_mask(1)
var n = randi() % (shellSounds.size() - 1) + 1
myAudio.stream = shellSounds[n]
myAudio.pitch_scale = random.randf_range(0.9, 1.1)
if myAudio.playing == false:
myAudio.play()