<!--
{
  "availability" : [
    "iOS: 18.0.0 -",
    "iPadOS: 18.0.0 -",
    "macCatalyst: 18.0.0 -",
    "macOS: 15.0.0 -",
    "tvOS: 26.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "RealityKit",
  "identifier" : "/documentation/RealityKit/OpacityComponent",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "RealityKit"
    ],
    "preciseIdentifier" : "s:17RealityFoundation16OpacityComponentV"
  },
  "title" : "OpacityComponent"
}
-->

# OpacityComponent

A component that controls the opacity of an entity and its descendants.

```
struct OpacityComponent
```

## Overview

An opacity component multiplies its
[`opacity`](/documentation/RealityKit/OpacityComponent/opacity) property with
all visual components the entity and its descendants own.
Visual components include [`ModelComponent`](/documentation/RealityKit/ModelComponent) and [`ParticleEmitterComponent`](/documentation/RealityKit/ParticleEmitterComponent).
If a descendant also has its own opacity component, the system combines the two opacities by multiplying their values.
The system repeats this pattern for the entity’s entire family tree.

For example, the following code sets a component’s opacity value
to `0.5` for its entity:

```swift
// Load a USDZ model from a file, or create a model component.
let robot = try await Entity(named: "vintage_robot")

// Create an opacity component.
let opacityComponent = OpacityComponent(opacity: 0.5)

// Apply the opacity component to the robot entity.
robot.components.set(opacityComponent)
```

The following images show robot models with opacity values of `1.0` and `0.5`.

|`opacity: 1`                                                                                                                                                                            |`opacity: 0.5`                                                                                                                                                                              |
|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
|![An image of an opaque vintage-style toy robot in a living room scene. The robot is facing about 45 degrees to the left and down from the viewer’s perspective.](opacitycomponent-full)|![An image of a translucent vintage-style toy robot in a living room scene. The robot is facing about 45 degrees to the left and down from the viewer’s perspective.](opacitycomponent-half)|

---

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)