Skip to main content

<pc-sound>

The <pc-sound> tag is used to define a sound.

Usage
  • It must be a direct child of a <pc-sounds> component.

Attributes

AttributeTypeDefaultDescription
assetString-Audio asset ID (must reference an audio type asset)
auto-playBoolean"false"Whether the sound plays automatically
durationNumber-Duration of the sound in seconds (omit to play the full clip)
loopBoolean"false"Whether the sound loops
nameString-Name identifier for the sound slot
overlapBoolean"false"Whether sounds can overlap when triggered multiple times
pitchNumber"1"Pitch multiplier (1 = normal pitch)
start-timeNumber"0"Start time offset in seconds
volumeNumber"1"Volume level (0-1)

Example

<pc-app>
<pc-asset src="assets/audio/music.mp3" id="music"></pc-asset>
<pc-scene>
<pc-entity>
<pc-sounds>
<pc-sound asset="music"></pc-sound>
</pc-sounds>
</pc-entity>
</pc-scene>
</pc-app>

JavaScript Interface

You can programmatically create and manipulate <pc-sound> elements using the SoundElement API.