Playing Sound in game?

Godot Version

4.2.2

Question

Hi all,

Just a really quick question. At the moment I am working on a tutorial and I don’t have time to import my sound module that I would like to use from another project.

So, in the meantime is it perfectly valid to use the code:

func _on_body_entered(body):
	if(body is hero):
	        .... 
		audio.play();
		await audio.finished;
		
		#kill off object
		queue_free();

And are there any caveats to be aware of using this code?

Thankyou and Regards.

Await does not block and there could be multiple on body entry calls.

2 Likes

Oh dear, wasn’t expecting that to be a problem, so, thankyou for that!

So, I have changed the code above that to read:

collision_mask = 0;

Would that stop that particular caveat?

1 Like

I think so, among other ways to disable collisions.

1 Like

There are other ways :open_mouth:. Anyways, thanks for the help!

It was most appreciated :sunglasses:.