# Source

<div align="left"><figure><img src="https://260262196-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FpYxFg97YnJX96UzNNTSd%2Fuploads%2Fgit-blob-e90aec6f7f5c8ee66628ea9fb325fef9c48da21a%2FSource_2.png?alt=media" alt=""><figcaption></figcaption></figure></div>

By using a Source script, new movable units [(MUs)](https://doc.realvirtual.io/components-and-scripts/mu-movable-unit) can be generated. MUs can be generated in intervals or automatically generated once the last generated [MU](https://doc.realvirtual.io/components-and-scripts/mu-movable-unit) has travelled a certain distance away from the source. This is useful to automatically generate[ MUs](https://doc.realvirtual.io/components-and-scripts/mu-movable-unit) on a conveyor. The object with the Source script attached to, is like a template. Each time a [MU](https://doc.realvirtual.io/components-and-scripts/mu-movable-unit) is created, the Source creates a new instance of the object under the defined root `Destination` in the scene hierarchy.

This tutorial shows how to create a custom source:

{% embed url="<https://youtu.be/3bquTLyGx3k>" %}
Tutorial custom sources
{% endembed %}

The source can also manually create [(MUs)](https://doc.realvirtual.io/components-and-scripts/mu-movable-unit) when you press "C". The source will delete all generated [(MUs)](https://doc.realvirtual.io/components-and-scripts/mu-movable-unit) when you press "D" on the keyboard.

This is the property window of the source:

<div align="left"><figure><img src="https://260262196-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FpYxFg97YnJX96UzNNTSd%2Fuploads%2Fgit-blob-0c4d9452e566b211e3c4ba092723a4f06fcfc3ae%2Fsource-inspector.png?alt=media" alt=""><figcaption></figcaption></figure></div>

### Properties <a href="#properties" id="properties"></a>

#### This Object as MU

Defines which part should be generated. Should normally point to the same GameObject where the source component itself is attached to. This is also the standard setting.

**Note:** Collider enabled/disabled states are preserved from this template when generating MUs. To disable specific colliders on generated MUs, simply disable them in the template prefab before starting the simulation.

#### Destination

When the source is generating a new MU it can be placed as a sub Gameobject under the defined Destination Gameobject.

#### Enabled

Must be set to true for the source to work.

#### Freeze Source Position

Should be usually set to true - the source will not change its position.

#### Don’t Visualize

Hides the source so that only the created MUs are visible.

#### Mass

Sets the Mass of the created MUs.

#### Set Center of Mass

Sets the Center of Mass of the created MUs.

#### Center of Mass

The Center of Mass.

#### Generate on Layer

Unity Layer where the MU should be placed to after creation.

#### On Create Destroy Components

Maybe some scripts on the MU, which is a copy of the source, should be destroyed when the MU is created. You can define here the components to be destroyed.

#### Create in Interval

Creates MUs in a constant interval in seconds. If the value is 0 this option is not used.

#### Automatic Generate On Distance

Automatically creates new MUs when the distance of the last created MU is greater than the defined value. Optionally the distance can be also randomly (equally distributed) between the defined Distance (“Generate if Distance”) plus / minus the “Range Distance”.

#### Number of MUs

Limits the number of generated MUs.

#### SourceIOs

Gernarate MU - should be turned on for making the source work.

#### Source Signals

PLCOutputBool Signal (e.g. from a PLC) for generating MUs.

#### Events

Unity Event which can be used for custom scripts which are called when an MU is created.

### Template Behavior

The Source GameObject acts as a non-physical template during simulation:

**Collider Handling:**

* All colliders on the template are automatically disabled when the simulation starts
* The initial enabled/disabled state of each collider is preserved from your prefab configuration
* When MUs are generated, each collider's original state is restored
* This includes colliders on inactive child GameObjects

**Practical Use:**

* To have a collider disabled on generated MUs, simply disable it in the template prefab before simulation starts
* To have a collider enabled on generated MUs, ensure it's enabled in the template prefab
* Inactive child GameObjects maintain their hierarchy state and collider configurations

**Visibility:**

* The template's visual representation can be hidden using the **Don't Visualize** property
* Even when hidden, the template remains in the scene as the blueprint for MU generation

**Physics:**

* The template does not participate in physics simulation
* Generated MUs have full physics interaction (collisions, rigidbodies, etc.)
* Use **Freeze Source Position** to prevent the template from moving

#### Public Interfaces

If script is attached to the Gameobject of the MU, which implements the Interface “ISourceCreated” a Method “OnSourceCreated” is called on the MU when it has been created by the MU.

#### Public properties and methods

Please check the [Realvirtual.io Class Reference](https://realvirtual.io/apidoc/classrealvirtual_1_1_source.html) for more information about the properties and methods of this component.

© 2025 realvirtual GmbH [https://realvirtual.io](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.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://doc.realvirtual.io/components-and-scripts/mu-movable-unit/source.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
