0 votes

This is my Code:

var speler = AudioStreamPlayer.new();

var first_time = true
var is_playing = false
func _physics_process(delta):
    if Input.is_action_just_pressed("primary_fire"):
        if  first_time:
            self.add_child(speler);
            speler.stream = load("res://Sounds/GunShot.wav");
            first_time = false
        if not is_playing:
            speler.play(true);
            is_playing = true

Is something wrong? when i press the key its doesnt play a sound
The key input for "primary_fire" = Left Click

Pls help me

Godot version 3.3.3
in Engine by (16 points)

1 Answer

0 votes

I just tested your script and it works, check the file name well or try another, the folder is Sounds, sounds, sound !? My version is v3.3.2.stable.oficial

by (2,058 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.