# ObjectPrivate

Kind: Class · Namespace: Sansar.Simulation · Assembly: Sansar.Simulation.dll · Script API 47.10.0

<div class="api-meta">
<span class="api-kind api-kind-class" data-pagefind-filter="kind:Class">Class</span>
<span data-pagefind-filter="namespace:Sansar.Simulation">Namespace <a href="/scripting/api/sansar.simulation"><code>Sansar.Simulation</code></a></span>
<span>Inherits <a href="/scripting/api/sansar.script/instanceinterface">Sansar.Script.InstanceInterface</a></span>
</div>

<span id="T:Sansar.Simulation.ObjectPrivate"></span>

Interface to an object in a [`Cluster`](/scripting/api/sansar.simulation/cluster) in the Scene.

```csharp
public class ObjectPrivate : Sansar.Script.InstanceInterface
```

## Remarks

Provides basic information about an object.

## Members at a glance

| Kind | Members |
|---|---|
| **Properties** | [ForwardVector](#forwardvector) · [InitialPosition](#initialposition) · [InitialRotation](#initialrotation) · [IsMovable](#ismovable) · [Mover](#mover) · [Name](#name) · [ObjectId](#objectid) · [Position](#position) · [RightVector](#rightvector) · [Rotation](#rotation) · [UpVector](#upvector) |
| **Methods** | [AddInteraction](#addinteraction) · [FindScripts](#findscripts) · [GetComponent](#getcomponent) · [GetComponentCount](#getcomponentcount) · [LookupScripts](#lookupscripts) · [ToString](#tostring) · [TryGetComponent](#trygetcomponent) · [TryGetFirstComponent](#trygetfirstcomponent) |

## Properties

### ForwardVector

<div class="api-card">
<span id="P:Sansar.Simulation.ObjectPrivate.ForwardVector"></span>

```csharp signature
public Sansar.Vector ForwardVector { get; }
```

The forward vector of the ObjectPrivate in the world frame.

**Value:** [Sansar.Vector](/scripting/api/sansar/vector) — A normalized vector.

</div>

### InitialPosition

<div class="api-card">
<span id="P:Sansar.Simulation.ObjectPrivate.InitialPosition"></span>

```csharp signature
public Sansar.Vector InitialPosition { get; }
```

The position of the ObjectPrivate in world frame before simulation started.

</div>

### InitialRotation

<div class="api-card">
<span id="P:Sansar.Simulation.ObjectPrivate.InitialRotation"></span>

```csharp signature
public Sansar.Quaternion InitialRotation { get; }
```

The rotation of the ObjectPrivate in world frame before simulation started.

</div>

### IsMovable

<div class="api-card">
<span id="P:Sansar.Simulation.ObjectPrivate.IsMovable"></span>
<div class="api-badges"><span class="api-badge api-since">Added in 32.0.0</span></div>

```csharp signature
public bool IsMovable { get; }
```



</div>

### Mover

<div class="api-card">
<span id="P:Sansar.Simulation.ObjectPrivate.Mover"></span>
<div class="api-badges"><span class="api-badge api-since">Added in 32.0.0</span></div>

```csharp signature
public Mover Mover { get; }
```



</div>

### Name

<div class="api-card">
<span id="P:Sansar.Simulation.ObjectPrivate.Name"></span>
<div class="api-badges"><span class="api-badge api-since">Added in 31.1.0</span></div>

```csharp signature
public string Name { get; }
```

This ObjectPrivate name, as specified in the editor.

</div>

### ObjectId

<div class="api-card">
<span id="P:Sansar.Simulation.ObjectPrivate.ObjectId"></span>

```csharp signature
public Sansar.Script.ObjectId ObjectId { get; }
```

This ObjectPrivate Id. Unique to this Scene.

</div>

### Position

<div class="api-card">
<span id="P:Sansar.Simulation.ObjectPrivate.Position"></span>

```csharp signature
public Sansar.Vector Position { get; }
```

The current position of the ObjectPrivate in world frame.

</div>

### RightVector

<div class="api-card">
<span id="P:Sansar.Simulation.ObjectPrivate.RightVector"></span>

```csharp signature
public Sansar.Vector RightVector { get; }
```

The right vector of the ObjectPrivate in the world frame.

**Value:** [Sansar.Vector](/scripting/api/sansar/vector) — A normalized vector.

</div>

### Rotation

<div class="api-card">
<span id="P:Sansar.Simulation.ObjectPrivate.Rotation"></span>

```csharp signature
public Sansar.Quaternion Rotation { get; }
```

The current rotation of the ObjectPrivate in the world frame.

</div>

### UpVector

<div class="api-card">
<span id="P:Sansar.Simulation.ObjectPrivate.UpVector"></span>

```csharp signature
public Sansar.Vector UpVector { get; }
```

The up vector of the ObjectPrivate in the world frame.

**Value:** [Sansar.Vector](/scripting/api/sansar/vector) — A normalized vector.

</div>


## Methods

### AddInteraction

<div class="api-card" id="addinteraction-string-boolean">
<span id="M:Sansar.Simulation.ObjectPrivate.AddInteraction(System.String,System.Boolean)"></span>

```csharp signature
public void AddInteraction(string prompt, bool enabled)
```

Add an Interaction to the object to make it clickable.

| Parameter | Type | Description |
|---|---|---|
| `prompt` | [string](https://learn.microsoft.com/dotnet/api/system.string) | The string prompt to show on hover, leave blank to only highlight the object. |
| `enabled` | [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | Whether or not the interaction is enabled. |

<details class="api-remarks"><summary>Remarks</summary>

The [`ObjectPrivate.AddInteractionData`](/scripting/api/sansar.simulation/objectprivate.addinteractiondata) will include the Interaction object which can be subscribed to.

</details>

</div>

<div class="api-card" id="addinteraction-string-boolean-action">
<span id="M:Sansar.Simulation.ObjectPrivate.AddInteraction(System.String,System.Boolean,System.Action{Sansar.Simulation.ObjectPrivate.AddInteractionData})"></span>

```csharp signature
public void AddInteraction(
    string prompt,
    bool enabled,
    Action<ObjectPrivate.AddInteractionData> handler
)
```

Add an Interaction to the object to make it clickable.

| Parameter | Type | Description |
|---|---|---|
| `prompt` | [string](https://learn.microsoft.com/dotnet/api/system.string) | The string prompt to show on hover, leave blank to only highlight the object. |
| `enabled` | [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | Whether or not the interaction is enabled. |
| `handler` | [Action&lt;ObjectPrivate.AddInteractionData&gt;](https://learn.microsoft.com/dotnet/api/system.action-1) | Handler to be called when the event completes. |

<details class="api-remarks"><summary>Remarks</summary>

The [`ObjectPrivate.AddInteractionData`](/scripting/api/sansar.simulation/objectprivate.addinteractiondata) will include the Interaction object which can be subscribed to.

</details>

</div>

### FindScripts

<div class="api-card" id="findscripts-noargs">
<span id="M:Sansar.Simulation.ObjectPrivate.FindScripts``1"></span>
<span id="M:Sansar.Simulation.ObjectPrivate.FindScripts``1()"></span>
<div class="api-badges"><span class="api-badge api-since">Added in 32.0.0</span></div>

```csharp signature
[Sansar.Script.NonReflective]
[System.Runtime.CompilerServices.IteratorStateMachine(typeof(Sansar.Simulation.ObjectPrivate/<FindScripts>d__52`1))]
public IEnumerable<TInterface> FindScripts<TInterface>() where TInterface : class
```

Looks up scripts on this ObjectPrivate that match the interface type.

**Type parameters:** `TInterface`: The interface to find.

**Returns:** [IEnumerable&lt;TInterface&gt;](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1) — An IEnumerable which contains all scripts of the given type name on this ObjectPrivate that match the given interface.

<details class="api-remarks"><summary>Remarks</summary>

The name given corresponds to the `Type.FullName` of the main script class. Multiple scripts may define unrelated types of the same name, but only registered scripts that match the interface of TInterface will be returned.

</details>

</div>

<div class="api-card" id="findscripts-string">
<span id="M:Sansar.Simulation.ObjectPrivate.FindScripts``1(System.String)"></span>

```csharp signature
[Sansar.Script.NonReflective]
[System.Runtime.CompilerServices.IteratorStateMachine(typeof(Sansar.Simulation.ObjectPrivate/<FindScripts>d__51`1))]
public IEnumerable<TInterface> FindScripts<TInterface>(
    string name
) where TInterface : class
```

Looks up scripts on this ObjectPrivate that match the interface type by class name.

| Parameter | Type | Description |
|---|---|---|
| `name` | [string](https://learn.microsoft.com/dotnet/api/system.string) | The type name of the script&#39;s class to find. |

**Type parameters:** `TInterface`: The interface to find.

**Returns:** [IEnumerable&lt;TInterface&gt;](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1) — An IEnumerable which contains all scripts of the given type name on this ObjectPrivate that match the given interface.

<details class="api-remarks"><summary>Remarks</summary>

The name given corresponds to the `Type.FullName` of the main script class. Multiple scripts may define unrelated types of the same name, but only registered scripts that match the interface of TInterface will be returned.

</details>

</div>

### GetComponent

<div class="api-card">
<span id="M:Sansar.Simulation.ObjectPrivate.GetComponent(Sansar.Simulation.ComponentType,System.UInt32)"></span>

```csharp signature
public object GetComponent(ComponentType componentType, uint index)
```

Get interfaces to the components that are available at runtime.

| Parameter | Type | Description |
|---|---|---|
| `componentType` | [ComponentType](/scripting/api/sansar.simulation/componenttype) | [`ComponentType`](/scripting/api/sansar.simulation/componenttype). |
| `index` | [uint](https://learn.microsoft.com/dotnet/api/system.uint32) | uint32 index |

**Returns:** [object](https://learn.microsoft.com/dotnet/api/system.object)

</div>

### GetComponentCount

<div class="api-card">
<span id="M:Sansar.Simulation.ObjectPrivate.GetComponentCount(Sansar.Simulation.ComponentType)"></span>

```csharp signature
public uint GetComponentCount(ComponentType componentType)
```

Get the number of components of a particular component type. [`ComponentType`](/scripting/api/sansar.simulation/componenttype)

| Parameter | Type | Description |
|---|---|---|
| `componentType` | [ComponentType](/scripting/api/sansar.simulation/componenttype) | [`ComponentType`](/scripting/api/sansar.simulation/componenttype) |

**Returns:** [uint](https://learn.microsoft.com/dotnet/api/system.uint32)

</div>

### LookupScripts

<div class="api-card">
<span id="M:Sansar.Simulation.ObjectPrivate.LookupScripts"></span>
<span id="M:Sansar.Simulation.ObjectPrivate.LookupScripts()"></span>

```csharp signature
public object[] LookupScripts()
```

Get handles to the scripts on the ObjectPrivate

**Returns:** [object](https://learn.microsoft.com/dotnet/api/system.object)\[\] — object \[\] of Objects of the scripts on the ObjectPrivate

<details class="api-remarks"><summary>Remarks</summary>

The returned Objects are the created script types. For example if a script on the object is `public MyTestObject : ObjectScript` then the Objects in the array will be of type `MyTestObject`.

</details>

</div>

### ToString

<div class="api-card">
<span id="M:Sansar.Simulation.ObjectPrivate.ToString"></span>
<span id="M:Sansar.Simulation.ObjectPrivate.ToString()"></span>

```csharp signature
public override string ToString()
```

A string representation of this object.

**Returns:** [string](https://learn.microsoft.com/dotnet/api/system.string) — A string representation of this object.

<details class="api-remarks"><summary>Remarks</summary>

The format of this string may change between releases.

</details>

</div>

### TryGetComponent

<div class="api-card">
<span id="M:Sansar.Simulation.ObjectPrivate.TryGetComponent``1(System.UInt32,``0@)"></span>

```csharp signature
public bool TryGetComponent<ComponentClass>(
    uint index,
    out ComponentClass component
) where ComponentClass : class
```

Try to get a component of a particular type from this ObjectPrivate

| Parameter | Type | Description |
|---|---|---|
| `index` | [uint](https://learn.microsoft.com/dotnet/api/system.uint32) | The index of this component type to get. zero based index. |
| `component` | ComponentClass | The component out parameter of the correct type to get. |

**Type parameters:** `ComponentClass`: The component type. [`AnimationComponent`](/scripting/api/sansar.simulation/animationcomponent) [`RigidBodyComponent`](/scripting/api/sansar.simulation/rigidbodycomponent)

**Returns:** [bool](https://learn.microsoft.com/dotnet/api/system.boolean) — True if a component of the correct type at index is found, false otherwise.

</div>

### TryGetFirstComponent

<div class="api-card">
<span id="M:Sansar.Simulation.ObjectPrivate.TryGetFirstComponent``1(``0@)"></span>

```csharp signature
public bool TryGetFirstComponent<ComponentClass>(
    out ComponentClass component
) where ComponentClass : class
```

Try to get the first component of a specific type on this ObjectPrivate

| Parameter | Type | Description |
|---|---|---|
| `component` | ComponentClass | Out parameter of the correct component type. |

**Type parameters:** `ComponentClass`: The component type. [`AnimationComponent`](/scripting/api/sansar.simulation/animationcomponent) and [`RigidBodyComponent`](/scripting/api/sansar.simulation/rigidbodycomponent)

**Returns:** [bool](https://learn.microsoft.com/dotnet/api/system.boolean) — Returns true if able to get a component of the correct type on this ObjectPrivate.

</div>


## Used in examples

- [FollowThePath.cs](/scripting/examples/follow-the-path)
- [MoverExample1.cs](/scripting/examples/mover-examples)
- [MoverExample2.cs](/scripting/examples/mover-examples)
- [MoverExample3.cs](/scripting/examples/mover-examples)
- [RandomMovement.cs](/scripting/examples/random-movement)
- [ReflectiveDetectorExample.cs](/scripting/examples/reflective-detector)
- [StatsExample.cs](/scripting/examples/stats-example)
- [AgentGravityExample.cs](https://github.com/Wookey-Technologies/sansar-script-starter/blob/66af8b516b701088d043e4615acfcf5779356604/examples/official/AgentGravityExample.cs)
- [AgentScaleExample.cs](https://github.com/Wookey-Technologies/sansar-script-starter/blob/66af8b516b701088d043e4615acfcf5779356604/examples/official/AgentScaleExample.cs)
- [AnimationExample.cs](https://github.com/Wookey-Technologies/sansar-script-starter/blob/66af8b516b701088d043e4615acfcf5779356604/examples/official/AnimationExample.cs)
- [BanHammerExample.cs](https://github.com/Wookey-Technologies/sansar-script-starter/blob/66af8b516b701088d043e4615acfcf5779356604/examples/official/BanHammerExample.cs)
- `CameraShakeExample.cs`

…and 43 more examples in the snapshot.

<p class="api-generated" data-pagefind-ignore>Generated from the Sansar 47.10.0 client ScriptApi snapshot.</p>