Chain
Last updated
Last updated
A chain is moving components along a spline path or a simulation path. This is useful for modeling for example for material handling or tool changers which are driven by chains. You can find at Assets/game4automation/Scenes/DemoChain a demo scene for the Chain. The usage of the simulation path is only possible with game4automation simulation, which is not included in game4automation. There are separated demos for this in game4automation simulation.
The usage of the simulation path is only possible with game4automation simulation, which is not included in game4automation. There are separated demos for this in game4automation simulation.
A chain is always connected to a drive. Thus, the movement of the chain always depends on the current drive position and speed. Usually, you should use a Drive in which the Axis is set to Virtual to move the chain.
To the chain one or several are connected. These are created automatically pon simulation start by the chain. Usually, these chain elements should be Prefabs inside your project.
On the same component where the Chain script is attached to, a Spline script needs to be attached. The spline script is defining the exact path of the chain based on points within and out tangents.
For extending a spline or for creating a first point you can push on the Extent button on the Spline. This will generate a Point with 2 included Tangent points. You can move these points like you can move any Gameobject to construct your spline. The order of these Gameobjects defines also 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.
The Chain Orientation determines whether the chain is horizotal or vertical. With Chain Element the prefab of the chain elements which should be placed along the spline needs to be assigned to the chain. The Connected Drive is moving the chain. The Number of Elements defines the number of elements that should be created upon simulation start on the chain. The start position is an offset in relation to the spline start. By selecting Calculate Delta Position the distance between the chain elements is calculated automatically based on the spline length and the number of elements. Enabling 'ScaledOnFixedLength' allows the spline to maintain a constant total length. This enables external drives to provide positional data for each ChainElement, which are then accurately mapped to their corresponding positions along the spline based on the fixed length.
Once the Unity Splines package is installed, the chain can be defined as follows.
In Project Settings > Player, add "REALVIRTUAL_SPLINES"
under Script Compilation Symbols to use the unity splines with realvirutal chain.
Right-click in the Hierarchy and select the desired base spline from the Spline menu. 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 in the picture below). This is relevant if you want to set up a vertical chain.
Add the ChainUnitySpline and Chain components to the created GameObject.
Once the chain is set up, it can be used with ChainElements and drives.
To construct the spline as described in the caption 'Constructing the spline' as a vertical chain, follow these steps:
Build the spline in the positive Z direction, starting from the bottom-right anchor point, and continue clockwise against the clock.
Maintain a vertical angle of exactly 90 degrees. Avoid inclinations to prevent misalignment with interpolated curves representing the height difference.
Note that these instructions are currently applicable only to splines with four anchor points and not more.
Ensure that the front of the chain element also faces in the positive Z direction. This orientation is necessary for the parent GameObject.
© 2025 realvirtualGmbH - 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.