<!--
{
  "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/InputTargetComponent",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "RealityKit"
    ],
    "preciseIdentifier" : "s:17RealityFoundation20InputTargetComponentV"
  },
  "title" : "InputTargetComponent"
}
-->

# InputTargetComponent

A component that gives an entity the ability to receive system input.

```
struct InputTargetComponent
```

## Overview

This component should be added to an entity to inform the system that it should be treated as
a target for input handling. It can be customized to require only specific forms of input like direct
or indirect interactions. By default the component is configured to handle all forms of input on the system.

The hit testing shape that defines the entity’s interactive entity is defined by the `CollisionComponent`.
To configure an entity for input but avoid any sort of physics-related processing, add an `InputTargetComponent`
and `CollisionComponent`, but disable the `CollisionComponent` for collision detection, for example:

```
// Enable the entity for input.
myEntity.components.set(InputTargetComponent())

// Create a collision component with an empty group and mask.
var collision = CollisionComponent(shapes: [.generateSphere(radius: 0.1)])
collision.filter = CollisionFilter(group: [], mask: [])
myEntity.components.set(collision)
```

`InputTargetComponent` behaves hierarchically, so if it is added to an entity that has
descendants with `CollisionComponent`s, those shapes will be used for input handling.
The `isEnabled` flag can be used to override this behavior by adding the `InputTargetComponent`
to a descendant and setting `isEnabled` to false.

`InputTargetComponent`’s `allowedInputTypes` property allows the entity to only receive
the provided types of input. This property also propagates down the hierarchy, but if a descendant
also has an `InputTargetComponent` defined, its `allowedInputTypes` property overrides
the value provided by the ancestor.

---

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)