Metaverse Interactable

MetaverseInteractable Documentation

The MetaverseInteractable component allows players to interact with objects on VR and non-VR platforms. It utilizes the Unity XR Interaction Toolkit and derives from XRSimpleInteractable.

Namespace

MetaverseCloudEngine.Unity.XR.Components

Public Methods

  • void StopNonVRAnimation(string animationName): Stops the specified non-VR animation if it is playing.

  • void PlayNextNonVRAnimation(): Plays the next available non-VR animation.

  • void PlayNonVRAnimation(string animationName): Plays the non-VR animation with the specified name.

  • void PlayNonVRAnimation(AvatarPlayableAnimationPreset anim): Plays the non-VR animation from the specified preset.

  • void ResetNonVRAnimationCooldown(): Resets the non-VR animation cooldown.

  • Vector3 GetInteractPosition(Transform interactableAttachPoint, Transform interactorAttachPoint, bool nonXR): Gets the target position of this interactable relative to the interactor attach point and interactable attach point.

  • MetaverseInteractableAttachPoint GetBestAttachPoint(bool leftHand, bool firstGrab): Gets the best attach point for the given hand.

  • void ForceLocalPlayerSelection(): Forces the local player to select this interactable.

  • void ForceDeselection(): Forces this interactable to be deselected by all currently selecting interactors.

Public Properties

  • bool AllowMultipleInteractors (read only): Whether to allow multiple interactors to select this interactable at the same time.

  • bool CanBeStolen: Whether to allow the player to steal this interactable from another player.

  • bool IsClimbable: Modifies the behavior of the interactable to be suitable for climbing.

  • bool AllowFlatSurfaceClimbing: Whether to allow the player to attach to flat surfaces when IsClimbable is true.

  • bool CollideWithPlayer: Whether to allow the player to collide with the object they're holding.

  • float PhysicsAttachmentBreakDistance: The maximum distance from the original grab point that the interactor can be before the grab breaks.

  • MetaverseInteractableAttachPoint Hand1AttachPoint (read only): The primary hand's attach point for this interactable.

  • MetaverseInteractableAttachPoint Hand2AttachPoint (read only): The secondary hand's attach point for this interactable.

Inspector Fields

  • bool canBeStolen: Whether or not this interactable can be stolen from another player.

  • bool enableRotation: Whether or not the player can rotate the object while holding it.

  • MetaverseInteractableAttachPoint[] attachPoints: Specific attach points for the left and right hands.

  • int nonVRDetachSocketType: The type of socket to attach this interactable to when it is deselected completely.

  • bool usePhysicsTracking: Whether or not to use physics-based tracking for VR and non-VR interactors.

  • bool enablePlayerCollision: Whether or not the player can collide with the object they're holding.

  • float breakDistance: The maximum distance from the original grab point that the interactor can be before the grab breaks.

  • UnityIkTarget leftHandIKTarget: The IK target for the left hand when using non-VR interaction.

  • bool nonVRRightHandAim: Whether or not the right hand should aim at the interactable when using non-VR interaction.

  • int upperBodyStyleID: The style to use for the character's upper body when using non-VR interaction.

  • UseAnimationSelectMode nonVRAnimationSelectMode: The selection mode to use for non-VR animations.

  • float nonVRSequenceResetCooldown: The cooldown time before the non-VR animation sequence is reset.

  • NonVRAnimation[] nonVRAnimations: The non-VR animations that can be played on this interactable.

Behavior

  • Execution Order: This class uses the int.MaxValue - 2 execution order, meaning it will be updated after most other components in the scene.

Usage

  1. To use MetaverseInteractable, start by adding the component to a GameObject in your scene.

  2. Configure the various options in the inspector to customize the behavior of your interactable.

  3. You can then use the public methods to control the interactable, such as playing animations or forcing selection.

Example:

You can use the MetaverseInteractable component to allow players to pick up and throw a ball. To do this:

  1. Add the MetaverseInteractable component to the ball GameObject.

  2. Ensure that the ball GameObject has a Rigidbody component.

  3. Configure the attachPoints property to specify where the player's hands should grab the ball.

  4. The player will then be able to pick up and throw the ball using their XR controllers or simulated hands.

Additional Notes

  • The MetaverseInteractable component is designed to be used with the MetaverseXRController component.

  • The MetaverseInteractable component can be used to create a variety of different interactions, such as picking up objects, throwing objects, opening doors, and climbing walls.

Last updated