Multiplayer wick help: trying to play a sound

Fill this out this info to make it easier for the community to help you! If you don’t fill out this information, your post may be deleted or removed.

What Wick Editor Version are you using?

Describe the Problem
I was using @SomeoneElse’s/@pumpkinhead’s websocket/cloud multiplayer template to mess around, and I was trying to make a thing where your player follows your mouse (that works) and by pressing “q” it plays a quack sound for everyone (not working so well).

in the latest working version, by holding q, you get “quack” text on top of your player, which everyone can see.

in the version that doesn’t work, the only difference is that I’ve added a playSound("quack"); line (the audio file was just named “quack”). suddenly, i can’t even see when I or another player quacks (no text and no sound). it’s still hold-to-quack so the outcome i’d expect is that the game plays the sound every frame (very fast, 60fps) for as long as i hold the “q” button.

What have you tried so far?
hard to say exactly what I’ve tried, but a few things I tried was switching the name of the file from Quack.wav to quack (which is what I have right now) and switching from hold-to-quack to press-to-quack (i don’t think i fully finished the attempt).

Do you have a Wick Editor File that we can see? Optional*
these 2 are of the version that don’t work. play the game with the HTML file, not the wick file. every time you want to playtest, you should export as HTML and try from there.
websocket quack7-24-2022_18-00-47.wick (9.4 KB)
My Project7-24-2022_17-59-21.html (2.1 MB)

this is the latest HTML that works. it shows text with no sound. if you comment out the playSounds from the wick file above and export to try, it should give you this.
My Project7-24-2022_17-58-24.html (2.1 MB)

1 Like

So the issue is that in the functions declared containing the playSound("quack") line, the project is undefined. Whenever you call the function playSound("quack") it really is window.project.playSound("quack"). In result you don’t have the sound play since it isn’t pointing to the intended function. Also since the class used to handle the client connection is a child of the window it does freeze the project like other errors in wick.

The easiest fix I reached was simply accessing the project through one of the clips as basically all classes in wick (aka Wick.Path, Wick.Clip and so on) contain the project. This then allows for it to access the needed function.

As for the reason to why the project is undefined in the functions I am not entirely sure but I have come across before.

This is the wick file I got working as a HTML. Also be prepared for a bombardment of quacks.
websocket quack7-24-2022_19-44-10.wick (9.4 KB)

1 Like

if you take this in a condescending tone then I’m sorry but add the sound to the frame

1 Like

Maybe just give your solution without preceding it with “don’t take this the wrong” because it wouldn’t have been taken the wrong way if you just give the solution but adding that actually turns it into a condescension.