---
title: PHASERandomNodeDefinition
framework: phase
role: symbol
role_heading: Class
path: phase/phaserandomnodedefinition
---

# PHASERandomNodeDefinition

A sound event node that invokes one of its child nodes at random.

## Declaration

```swift
class PHASERandomNodeDefinition
```

## Overview

Overview When the framework invokes a random node, it passes the invocation on to one of its children at random. The weight you choose for a child node in the addSubtree(_:weight:) argument skews the node’s selection chances. Choose from Alternate Sounds This class can model real-world cases where an event varies slightly, such as when footsteps sound slightly different because of the unique ground composition at each step.

The following code creates an instance of this class that selects from three different footstep sounds. The weights determine that an uncommon footstep noise plays half as frequently as the common footstep. And a third footstep noise plays 10% of the time.

## Topics

### Creating a Node

- [init()](phase/phaserandomnodedefinition/init().md)
- [init(identifier:)](phase/phaserandomnodedefinition/init(identifier:).md)

### Adding Descendent Nodes

- [addSubtree(_:weight:)](phase/phaserandomnodedefinition/addsubtree(_:weight:).md)

### Defining Selection Queue Length

- [uniqueSelectionQueueLength](phase/phaserandomnodedefinition/uniqueselectionqueuelength.md)

## Relationships

### Inherits From

- [PHASESoundEventNodeDefinition](phase/phasesoundeventnodedefinition.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)

## See Also

### Control Nodes

- [PHASESwitchNodeDefinition](phase/phaseswitchnodedefinition.md)
- [PHASEBlendNodeDefinition](phase/phaseblendnodedefinition.md)
- [PHASEContainerNodeDefinition](phase/phasecontainernodedefinition.md)
