Table of Contents

Class TrainARObject

Namespace
Interaction

The main behaviour script for a TrainAR object. This is automatically added when converting GameObject to TrainAR objects After adding this script all following RequiredComponents are added. SelectionBase, MeshCollider, BoxCollider, RigidbodyController, MaterialController, AudioController, Rigidbody, Outline, CollisionController. The TrainAR events that are triggered on actions are also defined in this script.

public class TrainARObject : MonoBehaviour
Inheritance
object
TrainARObject

Fields

Intersection

The Object this object is currently intersecting with.

[NonSerialized]
public CollisionController.Intersection Intersection

Field Value

CollisionController.Intersection

Is set on runtime.

OnCombination

public TrainARObject.CustomUnityEvent OnCombination

Field Value

TrainARObject.CustomUnityEvent

OnDeselect

public UnityEvent OnDeselect

Field Value

UnityEvent

OnGrabbed

public UnityEvent OnGrabbed

Field Value

UnityEvent

OnInteraction

public UnityEvent OnInteraction

Field Value

UnityEvent

OnReleased

public UnityEvent OnReleased

Field Value

UnityEvent

OnSelect

public UnityEvent OnSelect

Field Value

UnityEvent

TrainARObjectDisabled

If true the object is not selectable, grabbable, interactable, combineable but might be visible.

public bool TrainARObjectDisabled

Field Value

bool

Default is false.

error

Error event. Triggered when an action is triggered on this TrainAR object that was not accepted by the statemachine.

public UnityEvent error

Field Value

UnityEvent

interactableName

The name of the TrainAR object that is used for the statemachine check. By default, this is the name of the TrainAR object.

public string interactableName

Field Value

string

String based on the object name.

isCombinable

Is the object combineable?

public bool isCombinable

Field Value

bool

If true it is combinable.

isGrabbable

Is the object grabbable?

public bool isGrabbable

Field Value

bool

If true it is grabbable.

isGrabbed

public bool isGrabbed

Field Value

bool

isInteractable

Is the object interactable?

public bool isInteractable

Field Value

bool

If true it is interactable.

isSelected

public bool isSelected

Field Value

bool

lerpingDistance

The distance in front of the camera, where the object is lerped to. This can e.g. be useful, if objects are larger than usual.

public float lerpingDistance

Field Value

float

Default is 0.2f

pivotOffsetPosition

Offset of the pivot point. Use this, if the given pivot point by the model is weird.

public Vector3 pivotOffsetPosition

Field Value

Vector3

Default is (0, 0, 0).

pivotOffsetRotation

Offset of the pivot rotation. Use this, if the given pivot point by the model is weird.

public Vector3 pivotOffsetRotation

Field Value

Vector3

Default is (0, 0, 0).

Methods

Combine(string, GameObject)

Sends a request to the statemachine to check if this combine was valid. If so, the combine event of this TrainARObject is invoked otherwise the error event is invoked instead.

This does NOT physically combine the object, which has to be handled by hand or e.g. the TrainAR Object helper in the visual scripting.

public void Combine(string combinedWithName, GameObject intersectedObject)

Parameters

combinedWithName string
intersectedObject GameObject

Deselect()

Invokes the Deselect event of this TrainARObject and sets it's isSelected bool accordingly.

public void Deselect()

DisableTrainARObject()

Disables interactions with this TrainARObject by disabling it's colliders and Mesh Renderer.

public void DisableTrainARObject()

EnableTrainARObject()

Enables interactions with this TrainARObject by disabling it's colliders and Mesh Renderer.

public void EnableTrainARObject()

Error()

Invokes the error event of this TrainARObject.

public void Error()

Grab()

Sends a request to the statemachine to check if this grab was valid. If so, the grab event of this TrainARObject is invoked otherwise the error event is invoked instead.

This does NOT grab the object, which is handled in the InteractionController

public bool Grab()

Returns

bool

Interact(string)

Sends a request to the statemachine to check if this interaction was valid. If so, the interact event of this TrainARObject is invoked otherwise the error event is invoked instead.

public void Interact(string parameter = " ")

Parameters

parameter string

A string parameter which is passed to the statemachine.

Release()

Invokes the Release event of this TrainARObject and sets it's isGrabbed bool accordingly.

This does NOT release the object, which is handled in the InteractionController

public void Release()

Select()

Invokes the select event of this TrainARObject and sets it's isSelected bool accordingly.

public void Select()