API reference
API reference
Select your platform
No SDKs available
No versions available

IRelativeToRef Interface

IRelativeToRef provides a way to access a Unity Transform that may not be retreivable via the typical transform property.
If the Transform most relevant to the object is not the one it has direct access to as a Monobehaviour, but rather one it modifies as an interactable, RelativeTo accesses the relevant Transform.
The most common reason for needing IRelativeToRef is when an interactable (for example, DistanceGrabInteractable) resides on a GameObject which is not the root of the hierarchy to which the interactable "relates". A relatively common pattern in Interaction SDK organizes different types of IInteractables in different child GameObjects beneath the root GameObject which is conceptually "the interactable"; thus, a cube which can be both distance grabbed and selected with a poke might have a root GameObject, a child GameObject for the DistanceGrabInteractable and related scripts, another child GameObject for the PokeInteractable and related scripts, as well as other GameObjects for visuals, sounds, etc. In this case, the Transform most relevant to the DistanceGrabInteractable is not the one to which it has direct access as a MonoBehaviour, but rather the one it modifies as an interactable. IRelativeToRef characterizes this and provides a way to access this other Transform that the instance is "relative to".

Properties

Retrieves the Transform to which the current instance is related.
For example, if the implementing type is an IInteractable, RelativeTo should retrieve the Transform which represents the root of the conceptually "interactable" hierarchy, rather than the Transform of the GameObject to which the instance happens to be attached.
Did you find this page helpful?
Thumbs up icon
Thumbs down icon