Skip to content

ARC Session (Script Reference)

Giorgio edited this page Jul 8, 2021 · 3 revisions

SWITCH TO MANUAL

Description

Registers networked GameObjects for spawning and destroying them remotely. Manages creation of objects in the session local space, and performs raycasts in the same reference frame.

It is instantiated on each device, so you can attach additional scripts to the same GameObject to manage your custom app logic.

Properties

public GameObject[] sharedSessionPrefabs A list of all prefabs that can be instantiated across the network.
public static ARCSession session The session singleton reference.
public static Transform origin The Session Reference Frame Transform component. An ARAnchor component is attached to this GameObject's parent.
public static ARCSessionState sessionState The current session state enum value: Offline, Connecting, Setup, Lobby, Countdown, Playing.
public Vector3 sessionSpaceDisplacement Position offset of origin relative to its parent. This can be used to move the AR content without compromising the AR Anchor.
public float sessionSpaceOrientation Y-axis orientation offset of origin relative to its parent. This can be used to rotate the AR content without compromising the AR Anchor.

Public Methods

public static GameObject Spawn(GameObject entity, Vector3 position, Quaternion rotation) Server only, call via Command. Spawn an object across the network. entity must belong to sharedSessionPrefabs or be registered to the Client Scene. position and rotation are expressed in ARCSession.origin's local space.
public static void Destroy(GameObject entity) Server only, call via Command. Destroy an object across the network.
public static ARCEntity RaycastEntity(Vector3 from, Vector3 direction, float maxDistance, int layerMask) Perform a raycast in ARCSession.origin's local space and returns an ARCEntity, null otherwise. from and direction are expressed in ARCSession.origin's local space.
public static Vector3 RaycastPosition(Vector3 from, Vector3 direction, float maxDistance, int layerMask) Perform a raycast in ARCSession.origin's local space and returns a Vector3, Vector3.negativeInfinity otherwise. from and direction are expressed in ARCSession.origin's local space.
public void SetSessionSpacePose(Vector3 displacement, float orientation) Server only, call via Command. Move ARCSessionOrigin to displacement and rotates it along the Y-axis of orientation degrees. New position and rotation are defined in ARCSessionAnchor local space.

Clone this wiki locally