Premium Only Content
Rogue Engine - Playing Sounds - In Two Minutes
Rogue Engine enables you to attach a sound to an object in the scene.
So let's make an empty object and rename it.
We are going to create a new component to start the sound playing so, create a new Component asset and call it, Object Audio.
Now double click the component to open it in your code editor.
We need to reference the Three.js library at the top of the file as we want to add a property to the component that is a Three.Audio type.
The "true" parameter in the property indicates that this will be positional audio so that the sound will seem to come from the object in 3D space.
If we save our code and go back to the Rogue editor, we can drag and drop the component onto the Audio Background object. We will now see the objectAudio property we have defined is "unset".
So lets find some audio to go into this component. You can import an mp3 file into your asset panel and then drag and drop it into the objectAudio property.
Now we can go back to our code. We can make the audio play as soon as the scene is loaded by adding the following to the Start method.
First check that the objectAudio property has been set.
Then add the objectAudio to the object3D that this component is attached to.
We can set the audio to loop if we want to, then play the audio.
Save your code and go back to the Rogue editor. Now when we play our scene, the audio will play.
And that's how to attach audio to an object with Rogue Engine.
-
0:43
WildCreatures
2 days ago $2.38 earnedDiver is swallowed up by a passing bait ball at Darwin Island
4.89K4 -
1:54
Damon Imani
3 days agoDamon Left The View SPEECHLESS on Marriage And Government Overreach
5.99K9 -
4:09
Memology 101
14 hours ago $0.72 earned"Journalist" REPEATEDLY tries and FAILS to bait John Fetterman into calling Trump an "AUTOCRAT"
4.84K16 -
58:02
Dialogue works
2 days ago $5.97 earnedMatthew Hoh: Ukraine’s Army Is COLLAPSING Everywhere!
28.2K18 -
17:24
Nate The Lawyer
2 days ago $2.18 earnedBREAKING: NEW Scientific Evidence Shows Men Are Better in Sports Than Women
13.7K12 -
29:43
Code Blue Cam
2 days agoHow Missing Dipping Sauce Turned into a Felony Arrest
15.8K14 -
16:19
BlaireWhite
2 days agoWoman Confronts "Trans Woman" In Locker Room: Gold's Gym Scandal
15.3K14 -
2:15:40
Side Scrollers Podcast
21 hours agoWTF Happened to Call of Duty?! + Ubisoft’s MAJOR F Up + Vtuber HIT LIST + More | Side Scrollers
68.3K16 -
18:31
Nikko Ortiz
17 hours agoKaren You Need A Shower...
15.5K12 -
9:47
MattMorseTV
18 hours ago $17.18 earnedDemocrats CAUGHT in $15,000,000 LIE.
26.7K49