<!--
{
  "availability" : [
    "iOS: 18.0.0 -",
    "iPadOS: 18.0.0 -",
    "macCatalyst: 18.0.0 -",
    "macOS: 15.0.0 -",
    "tvOS: 26.0.0 -",
    "visionOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "RealityKit",
  "identifier" : "/documentation/RealityKit/PlayAudioAction/init(targetEntity:audioResourceName:gain:useControlledPlayback:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "RealityKit"
    ],
    "preciseIdentifier" : "s:17RealityFoundation15PlayAudioActionV12targetEntity17audioResourceName4gain21useControlledPlaybackAcA0eG10ResolutionO_SSSdSbtcfc"
  },
  "title" : "init(targetEntity:audioResourceName:gain:useControlledPlayback:)"
}
-->

# init(targetEntity:audioResourceName:gain:useControlledPlayback:)

Creates a new play audio action.

```
init(targetEntity: ActionEntityResolution = .sourceEntity, audioResourceName: String, gain: Audio.Decibel = 0, useControlledPlayback: Bool = true)
```

## Parameters

`targetEntity`

The entity to play the audio.

`audioResourceName`

The name of the audio stored in audio library component of the target entity to start playing.

`gain`

The individual gain in decibels of the audio.

`useControlledPlayback`

Determines whether this action has control over the playback of the audio.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)