Chain

Chains move components along spline paths or simulation paths for material handling systems, tool changers, and other applications requiring continuous linear motion.

New Feature: Burst Compiler optimization was added in realvirtual 6.0.9 (beta) providing 20-33x performance improvements for chain simulations.

Overview

Chains provide continuous movement of multiple components along a defined path. This is useful for modeling material handling systems or tool changers that are driven by chains. They are always connected to a Drive component that controls the chain's movement speed and position. Chain elements are automatically created and positioned along the spline during simulation.

Chains work with both custom splines and Unity Splines. We recommend using Unity Splines for better editor integration and visual feedback.

You can find a demo scene at Assets/realvirtual/Scenes/DemoChain demonstrating chain functionality.

Basic Concepts

A chain is always connected to a drive, so the movement of the chain depends on the current drive position and speed. Usually, you should use a Drive with the Axis set to Virtual to move the chain.

One or several Chain Elements are connected to the chain. These Chain Elements are created automatically upon simulation start by the chain. Usually, these chain elements should be Prefabs within your project.

The Chain script requires a Spline script to be attached to the same component. The spline script defines the exact path of the chain based on points with in and out tangents.

Properties

Settings

Chain Orientation

Determines whether the chain moves horizontally or vertically.

  • Type: Enum (Horizontal, Vertical)

  • Default: Horizontal

  • Use case: Set based on your mechanical system orientation

Chain Element

Prefab used for individual chain elements along the spline.

  • Type: GameObject reference

  • Default: None

  • Use case: Assign your custom chain link or carrier prefab

Connected Drive

Drive component that controls chain movement.

  • Type: Drive reference

  • Default: None

  • Use case: Connect to a Drive with Virtual axis for chain control

Number of Elements

Total number of chain elements created along the spline.

  • Type: Integer

  • Default: 10

  • Range: 1 to 1000

  • Use case: Adjust based on spline length and element spacing needs

Start Position

Offset position along the spline where the first element is placed.

  • Type: Float

  • Default: 0

  • Range: 0 to spline length

  • Use case: Adjust starting position for alignment with mechanical systems

Calculate Delta Position

Automatically calculates spacing between chain elements.

  • Type: Boolean

  • Default: true

  • Use case: Enable for even distribution, disable for custom spacing

Scaled On Fixed Length

Maintains constant total spline length for external drive positioning.

  • Type: Boolean

  • Default: false

  • Use case: Enable when external drives provide positional data for elements

Performance Optimization

Burst Compiler Optimization

This feature was added in realvirtual 6.0.9 (beta)

The Chain component supports Unity's Burst Compiler for dramatically improved performance when simulating large numbers of chain elements. This optimization uses SIMD (Single Instruction, Multiple Data) compilation to native code, providing:

Performance Benchmarks:

  • Kinematic elements (MoveRigidBody=false): 29-33x speedup

  • Physics elements (MoveRigidBody=true): 19-23x speedup

How It Works

Burst optimization operates in two modes depending on your chain element configuration:

Kinematic Mode (Maximum Performance)

  • Uses Unity's TransformAccessArray for parallel batch processing

  • Ideal for visual chain elements without physics interactions

  • Achieves 29-33x performance improvement

  • Set MoveRigidBody=false on ChainElements to use this mode

Physics Mode (High Performance)

  • Uses traditional Rigidbody updates with Burst-compiled calculations

  • Required when chain elements need collider interactions

  • Achieves 19-23x performance improvement

  • Set MoveRigidBody=true on ChainElements for physics

Setup Instructions

One-Click Setup (Recommended)

If Burst optimization is not enabled, you'll see a warning message in the Chain Inspector with performance information and a setup button.

Chain Inspector showing Burst optimization not enabled with one-click setup button
  1. Click Enable Burst Optimization (Install Package & Define) button in the Chain Inspector

  2. Unity will automatically:

    • Install the Burst Compiler package

    • Add REALVIRTUAL_BURST to Script Compilation Symbols

    • Recompile scripts with Burst optimization enabled

  3. Restart Unity if prompted

Manual Setup

  1. Install Unity Burst Compiler package via Package Manager

  2. Add REALVIRTUAL_BURST to Project Settings > Player > Script Compilation Symbols

  3. Unity will automatically recompile with Burst optimization

After Setup

Once enabled, the Chain Inspector displays confirmation of active optimization:

Chain Inspector with Burst optimization enabled showing performance tips

Optimizing Chain Elements

For maximum performance, configure your ChainElements based on their purpose:

Visual-Only Elements (Fastest)

  • Set MoveRigidBody=false on the ChainElement component

  • Use for chain links, carriers, or fixtures that don't need physics

  • Achieves 29-33x speedup with kinematic batch processing

Physics-Interactive Elements

  • Set MoveRigidBody=true on the ChainElement component

  • Required for elements with colliders that interact with other objects

  • Still achieves 19-23x speedup with Burst-optimized physics updates

ChainElement Inspector showing MoveRigidBody property with performance guidance

The ChainElement Inspector provides inline performance tips to help you choose the right setting.

Advanced Settings

Spline Bake Resolution

  • Controls the number of pre-calculated spline samples used by Burst jobs

  • Higher values = smoother interpolation but more memory usage

  • Default: 100 samples

  • Adjust based on spline complexity and available memory

Use Burst Optimization

  • Enable/disable Burst processing at runtime

  • Defaults to enabled when REALVIRTUAL_BURST is defined

  • Useful for performance comparisons or debugging

Common Use Cases

High-Speed Bucket Elevators

  • Set MoveRigidBody=false on buckets for 29-33x speedup

  • Buckets follow path without physics interaction

  • Ideal for material transport visualization

Overhead Conveyors with Load Detection

  • Set MoveRigidBody=true on carriers for physics-based load pickup

  • Still achieves 19-23x speedup while maintaining collision detection

  • Necessary when carriers interact with sensors or parts

Mixed Configuration

  • Combine kinematic and physics elements in the same chain

  • Use physics only where needed (e.g., pickup/drop zones)

  • Optimize performance while maintaining required functionality

Technical Details

Burst optimization works by:

  1. Pre-calculating spline positions and tangents into native arrays

  2. Batch-processing all element position updates in parallel

  3. Using SIMD instructions for vectorized calculations

  4. Minimizing managed-to-native transitions

The system automatically handles:

  • Spline position interpolation

  • Tangent calculation for element orientation

  • Batch updates synchronized with drive events

  • Memory management for native arrays

Usage Examples

Basic Chain Setup

  1. Create a spline path using Unity Splines or custom spline

  2. Add Chain component to the spline GameObject

  3. Add ChainUnitySpline component for Unity Splines integration

  4. Assign Chain Element prefab

  5. Connect to a Drive component with Virtual axis

  6. Set Number of Elements based on your requirements

Unity Splines Integration

We recommend using Unity Splines for the chain. To do so, the Unity Splines package must be installed.

Once the Unity Splines package is installed, the chain can be defined as follows:

  1. In Project Settings > Player, add REALVIRTUAL_SPLINES under Script Compilation Symbols to use Unity Splines with realvirtual chains

  2. Right-click in the Hierarchy and select the desired base spline from the Spline menu

  3. Unity provides a Spline editing mode in the Scene view for adjusting spline control points. For each spline control point, Unity also shows the up direction at the point (red arrow). This is relevant if you want to set up a vertical chain

  4. Add the ChainUnitySpline and Chain components to the created GameObject

Once the chain is set up, it can be used with ChainElements and drives.

Vertical Chain Configuration

To construct a vertical chain, follow these steps:

  1. Build the spline in the positive Z direction, starting from the bottom-right anchor point, and continue clockwise

  2. Maintain a vertical angle of exactly 90 degrees. Avoid inclinations to prevent misalignment with interpolated curves representing the height difference

  3. Note that these instructions are currently applicable only to splines with four anchor points and not more

  4. Ensure that the front of the chain element also faces in the positive Z direction. This orientation is necessary for the parent GameObject

  5. Set Chain Orientation to Vertical

💡 Hint For vertical chains, use exactly four anchor points and maintain precise 90-degree angles to prevent misalignment with interpolated curves.

Editor Tools

Spline Construction

For extending a spline or creating a first point, you can click the Extend button on the Spline. This generates a Point with 2 included Tangent points. You can move these points like any GameObject to construct your spline. The order of these GameObjects also defines the order of the points in the spline. If you select Loop, the spline is closed and the last point is connected to the first point of the spline.

Unity Splines Editor

  • Visual spline editing in Scene view

  • Control point manipulation with handles

  • Up direction indicators (red arrows) for vertical chain setup

  • Real-time spline preview and adjustment

See Also


© 2025 realvirtual GmbH https://realvirtual.io - All rights reserved. No part of this publication may be reproduced, distributed, or transmitted in any form or by any means, including printing, saving, photocopying, recording, or other electronic or mechanical methods, without the prior written permission of the publisher.

Last updated