Chain

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

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

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