18 lines
419 B
GDScript3
18 lines
419 B
GDScript3
|
|
extends Node3D
|
||
|
|
|
||
|
|
var is_playing: bool = false
|
||
|
|
|
||
|
|
@onready var audio_player: SpatialAudio3D = %SpatialAudio3D
|
||
|
|
@onready var audiostream_player: AudioStreamPlayer3D = %AudioStreamPlayer3D
|
||
|
|
|
||
|
|
func toggle():
|
||
|
|
is_playing = !is_playing
|
||
|
|
if is_playing:
|
||
|
|
audio_player.do_play()
|
||
|
|
else:
|
||
|
|
audio_player.do_stop()
|
||
|
|
|
||
|
|
# Called when the node enters the scene tree for the first time.
|
||
|
|
func _ready() -> void:
|
||
|
|
%Button.pressed.connect(toggle)
|