### Unity: Interaction System Example Source: https://valvesoftware.github.io/steamvr_unity_plugin/index An extensive example scene showcasing advanced VR interactions, including picking up and throwing objects, and animated hands. This sample is located within the Interaction System directory and provides a comprehensive guide to using the plugin's features. ```Unity /SteamVR/Interaction System/Samples/Interactions_Example ``` -------------------------------- ### Interaction System Examples Source: https://valvesoftware.github.io/steamvr_unity_plugin/articles/intro The Interaction System provides ready-to-use examples and components for common VR interactions, built upon SteamVR Input and Skeleton Input. It covers object manipulation, UI interaction, and locomotion. ```APIDOC Interaction System: Purpose: A framework for common VR interactions in Unity. Features: - Unity UI Interaction: Enables interaction with standard Unity UI elements. - Pickup, Drop, Throw: Mechanics for picking up, dropping, and throwing objects. - Throwing Velocities: Variations for realistic object throwing. - Bow and Arrow: Example implementation for archery mechanics. - Wheel Interactions: Components for circular selection or manipulation. - Proximity Button: A button activated by proximity. - Skeleton Input Examples: Demonstrations of using hand tracking data. - Teleporting: Locomotion system for moving within VR environments. - Held Objects: Management of objects currently held by the player. - Skeleton Hand Grasping: Using skeleton data to form a hand around held objects. Dependencies: - SteamVR Plugin - SteamVR Input - SteamVR Skeleton Input Usage: - Explore the sample scenes provided with the plugin to see these features in action. - Integrate provided prefabs and scripts into your own projects. ``` -------------------------------- ### Unity: SteamVR Input Actions Setup Source: https://valvesoftware.github.io/steamvr_unity_plugin/index To utilize the SteamVR Input System, developers need to open the SteamVR Input window, copy example JSON files, and then save and generate input actions. This process sets up the necessary configuration for controller input handling within Unity projects. ```Unity Window -> SteamVR Input Click 'Yes' to copy example jsons Click 'Save and Generate' to create input actions. ``` -------------------------------- ### Unity: Simple Sample Scene Source: https://valvesoftware.github.io/steamvr_unity_plugin/index A basic sample scene is provided within the plugin to demonstrate the most straightforward implementation of VR with tracked controllers. This scene serves as a starting point for developers to integrate VR functionality. ```Unity /SteamVR/Simple Sample ``` -------------------------------- ### Hint System Source: https://valvesoftware.github.io/steamvr_unity_plugin/articles/Interaction-System The hint system displays contextual information on the controllers, allowing for individual button callouts and text-based hints. ```APIDOC System: Hints Purpose: Displays hints on controllers. Features: - Supports calling out individual controller buttons. - Ability to show text hints associated with buttons. ``` -------------------------------- ### API Documentation Link Source: https://valvesoftware.github.io/steamvr_unity_plugin/index This website contains links to API-level documentation for the SteamVR Unity Plugin. Developers can find detailed information about the plugin's interfaces and functionalities through these resources. ```APIDOC See: [API level documentation](api/index.html) ``` -------------------------------- ### SteamVR Input System Concepts Source: https://valvesoftware.github.io/steamvr_unity_plugin/articles/intro Abstracts controller input by referencing actions rather than specific buttons. This allows for user remapping and easier adaptation to new input devices without code changes. ```APIDOC SteamVR Input System: Purpose: Provides an action-based input system for VR controllers. Key Concepts: - Actions: Abstract representations of user inputs (e.g., 'Grab', 'Teleport'). - Bindings: Mapping physical controller inputs to actions. - User Rebinding: Allows users to customize input mappings. Benefits: - Simplifies input handling by focusing on intent (actions) rather than specific buttons. - Enables cross-device compatibility and future-proofing. - Supports community-driven binding sharing. Usage: - Define actions in the SteamVR Input configuration. - Use SteamVR Input API (e.g., SteamVR_Input_Manager) in scripts to read action states. - Example: // Get the state of a 'Grab' action: // SteamVR_Action_Boolean grabAction = SteamVR_Input.GetAction("Grab"); // if (grabAction.GetStateDown(SteamVR_Input_Sources.Any)) { // Debug.Log("Grab action initiated!"); // } ``` -------------------------------- ### Accessing SteamVR Actions by Name Source: https://valvesoftware.github.io/steamvr_unity_plugin/api/index Demonstrates how to retrieve specific SteamVR actions using generic or type-specific helper functions within the SteamVR_Input class. It also shows how to access actions via their full path for better performance or when dealing with many actions. ```csharp SteamVR_Input.GetAction("Plant"); SteamVR_Input.GetBooleanAction("Plant"); SteamVR_Input.GetActionByPath("/Farming/in/Plant"); ``` -------------------------------- ### Render Models and Pose Tracking Source: https://valvesoftware.github.io/steamvr_unity_plugin/articles/intro Utilize SteamVR components to display accurate 3D models of VR devices and track their position and rotation. The SteamVR_RenderModel component automatically loads device models, while SteamVR_Behaviour_Pose provides transform data. ```APIDOC SteamVR_RenderModel: Purpose: Automatically loads and displays the 3D model for a detected VR device. Usage: Attach to a GameObject to visualize the device. Dependencies: Requires a SteamVR_Behaviour_Pose component on the same or a parent GameObject to receive pose data. SteamVR_Behaviour_Pose: Purpose: Retrieves and applies the position and rotation data for a tracked VR device. Usage: Attach to a GameObject to track a controller or headset. Parameters: - deviceIndex: The index of the tracked device (e.g., 0 for HMD, 1 for first controller). - poseAction: The SteamVR Input action to bind the pose to (optional). Output: Updates the GameObject's transform to match the device's pose. Example: // Attach SteamVR_RenderModel to a GameObject with SteamVR_Behaviour_Pose to show controller model // Example usage in a C# script: // public SteamVR_Behaviour_Pose poseSource; // public SteamVR_RenderModel renderModel; // void Start() { // renderModel.SetDeviceIndex(poseSource.GetDeviceIndex()); // } ``` -------------------------------- ### Controller Button Hint System API Source: https://valvesoftware.github.io/steamvr_unity_plugin/articles/Interaction-System Provides static methods to manage visual button hints on SteamVR controllers. These hints can be simple flashes or include text. The system relies on SteamVR's mapping of render model components to button IDs to identify which part of the controller corresponds to a button. ```APIDOC ControllerButtonHints: ShowButtonHint(hand: SteamVR_Input_Source, button: string) - Flashes the specified button on the specified hand. - Parameters: - hand: The controller input source (e.g., LeftHand, RightHand). - button: The identifier for the button to flash. HideButtonHint(hand: SteamVR_Input_Source, button: string) - Stops flashing the specified button on the specified hand. - Parameters: - hand: The controller input source. - button: The identifier for the button to stop flashing. HideAllButtonHints(hand: SteamVR_Input_Source) - Stops flashing all buttons on the specified hand. - Parameters: - hand: The controller input source. IsButtonHintActive(hand: SteamVR_Input_Source, button: string): bool - Checks if a specified button is currently flashing on the specified hand. - Parameters: - hand: The controller input source. - button: The identifier for the button to check. - Returns: True if the button hint is active, false otherwise. ShowTextHint(hand: SteamVR_Input_Source, button: string, text: string) - Shows a text hint associated with the specified button on the specified hand. - Parameters: - hand: The controller input source. - button: The identifier for the button to associate the text hint with. - text: The string to display as the hint. HideTextHint(hand: SteamVR_Input_Source, button: string) - Hides the text hint for the specified button on the specified hand. - Parameters: - hand: The controller input source. - button: The identifier for the button whose text hint should be hidden. HideAllTextHints(hand: SteamVR_Input_Source) - Hides all active text hints on the specified hand. - Parameters: - hand: The controller input source. GetActiveHintText(hand: SteamVR_Input_Source, button: string): string - Gets the active hint text for a specified button on the specified hand. - Parameters: - hand: The controller input source. - button: The identifier for the button to retrieve the hint text from. - Returns: The active hint text, or an empty string if none is active. ``` -------------------------------- ### Teleport System Overview Source: https://valvesoftware.github.io/steamvr_unity_plugin/articles/Interaction-System The core logic for the teleport system is managed by the Teleport class, typically found within the Teleporting prefab. This system enables players to move to designated TeleportPoints or TeleportAreas within a VR scene. ```APIDOC Class: Teleport Purpose: Handles the primary logic for teleportation, including showing the teleport pointer on touchpad press and executing the teleport upon release. Functionality: - Manages teleport markers in the scene. - Handles fading to black during teleportation. - Supports tracing to a floor mesh for accurate player placement. Properties: - tracerLayerMask: Layers the teleport pointer attempts to hit. - floorFixupMask: The layer assigned to the floor mesh. - floorFixupMaximumTraceDistance: Max distance for tracing to find the floor. - ShowPlayAreaMarker: Toggles the display of the player's play area rectangle during teleport. - arcDistance: Determines the maximum range of the teleport arc. ``` -------------------------------- ### SteamVR_Behaviour Helper Components Source: https://valvesoftware.github.io/steamvr_unity_plugin/api/index These components (SteamVR_Behaviour_Boolean, SteamVR_Behaviour_Single, SteamVR_Behaviour_Vector2, SteamVR_Behaviour_Vector3) offer simplified access to specific action types and integrate with UnityEvents. They are designed for common scenarios and provide helpful functions for managing actions within the Unity event system. ```csharp // Example: Using SteamVR_Behaviour_Boolean for a button press. // Attach SteamVR_Behaviour_Boolean to a GameObject. // In the Inspector, assign a UnityEvent to be triggered on action events (e.g., OnPressDown). ``` -------------------------------- ### SteamVR Unity Plugin Hand Class API Source: https://valvesoftware.github.io/steamvr_unity_plugin/articles/Interaction-System Details the Hand class, its role in object interaction, messaging, attachment, and customizable properties within the SteamVR Unity Plugin. ```APIDOC Hand Class: The Hand class manages object interaction, detecting hover states, and sending messages to Interactable objects. Messages Sent to Objects: OnHandHoverBegin: Sent when the hand first starts hovering over an object. HandHoverUpdate: Sent every frame the hand is hovering over an object. OnHandHoverEnd: Sent when the hand stops hovering over an object. OnAttachedToHand: Sent when the object gets attached to the hand. HandAttachedUpdate: Sent every frame while the object is attached to the hand. OnDetachedFromHand: Sent when the object gets detached from the hand. OnHandFocusLost: Sent when an attached object loses focus (e.g., another object attached). OnHandFocusAcquired: Sent when an attached object gains focus (e.g., previous focus object detached). Messages Sent to Child Objects: OnHandInitialized: Sent when the hand is initialized with a device ID. OnParentHandHoverBegin: Sent when the hand starts hovering over something. OnParentHandHoverEnd: Sent when the hand stops hovering over something. OnParentHandInputFocusAcquired: Sent when the game window gains input focus. OnParentHandInputFocusLost: Sent when the game window loses input focus. Attachment Members: AttachObject(object obj, AttachmentFlags flags): Attaches an object to the hand with specified flags. DetachObject(object obj, bool restoreOriginalParent = false): Detaches an object from the hand, optionally restoring its original parent. currentAttachedObject: Property returning the in-focus attached object, if any. Properties and Functions: OtherHand: Property referencing the other hand of the player. HoverSphereTransform: Transform used to customize the hover range. Radius: Float value for the hover range radius. HoverLayerMask: LayerMask to filter which objects the hand can hover over. HoverUpdateInterval: Float to control the frequency of hovering checks. HoverLock(object obj): Locks the hand to hover only over a specific object (pass null to hover over nothing). Unlock(): Removes the hover lock. GetGrabStarting(GrabType grabType): Returns true if the specified grab action (grip or pinch) is starting. GetGrabEnding(GrabType grabType): Returns true if the specified grab action (grip or pinch) is ending. GetAttachmentTransform(string transformName): Returns a named child transform on the hand for snapping objects. ``` -------------------------------- ### Teleport Arc and Trace Handling Source: https://valvesoftware.github.io/steamvr_unity_plugin/articles/Interaction-System The TeleportArc component is responsible for drawing the visual teleport arc and performing the necessary physics traces to determine valid teleport destinations. ```APIDOC Class: TeleportArc Purpose: Draws the teleport arc and performs physics traces for the teleport system. Functionality: - Visualizes the path the player can teleport along. - Interacts with the scene's physics to find valid landing spots. ``` -------------------------------- ### Accessing SteamVR Input States Directly Source: https://valvesoftware.github.io/steamvr_unity_plugin/api/index Illustrates how to directly query the state of an action, such as checking if a boolean action was pressed down. This method requires specifying the action name and the input source (e.g., LeftHand, RightHand, Any). ```csharp SteamVR_Input.GetStateDown("Plant", SteamVR_Input_Sources.LeftHand); ``` -------------------------------- ### Render Model Component Source: https://valvesoftware.github.io/steamvr_unity_plugin/articles/Interaction-System The Render_Model component, distinct from SteamVR_Render_Model, manages both controller and hand models, allowing for individual enabling and disabling. ```APIDOC Class: Render_Model (Interaction System) Purpose: Handles controller and hand models within the Interaction System. Features: - Manages both controller and hand models. - Allows individual enabling/disabling of models. ``` -------------------------------- ### Teleport Markers Source: https://valvesoftware.github.io/steamvr_unity_plugin/articles/Interaction-System Teleport markers define locations players can teleport to. TeleportArea allows teleportation to the exact pointed location, while TeleportPoint teleports to a fixed origin. Both require a collider. ```APIDOC Class: TeleportMarkerBase Purpose: Base class for all teleport markers, defining expected methods for the Teleport class. Features: - Can be used as a base for custom marker types. - Supports locking/unlocking markers, preventing teleportation to locked ones. Class: TeleportArea Inherits: TeleportMarkerBase Purpose: Allows teleportation to a mesh-based area. Behavior: - Player teleports to the exact pointed location (with floor fixup). Requirements: - Requires a collider and mesh renderer on the GameObject. Class: TeleportPoint Inherits: TeleportMarkerBase Purpose: Defines specific points for teleportation. Behavior: - Player teleports to the origin of the point, regardless of where they pointed. Features: - Points can be named. - Supports teleporting to new scenes (requires integration with scene loading system). ``` -------------------------------- ### SteamVR_Behaviour_Skeleton Methods Source: https://valvesoftware.github.io/steamvr_unity_plugin/articles/Skeleton-Input Provides methods for controlling skeletal animation blending and pose manipulation within the SteamVR Unity plugin. ```APIDOC SteamVR_Behaviour_Skeleton: SetRangeOfMotion(EVRSkeletalMotionRange newRangeOfMotion, float blendOverSeconds = 0.1f) - Blends the skeleton's bones to a new specified range of motion over a given duration. - Parameters: - newRangeOfMotion: The target skeletal motion range (e.g., FEET, HANDS). - blendOverSeconds: The time in seconds over which to perform the blend (defaults to 0.1f). BlendToSkeleton(float overTime = 0.1f) - Fully blends the skeleton's animation to use direct skeleton input data. - Parameters: - overTime: The time in seconds over which to complete the blend (defaults to 0.1f). BlendToPoser(SteamVR_Skeleton_Poser poser, float overTime = 0.1f) - Fully blends the skeleton's animation to use data from a specified SteamVR_Skeleton_Poser. - Parameters: - poser: The SteamVR_Skeleton_Poser component to blend to. - overTime: The time in seconds over which to complete the blend (defaults to 0.1f). BlendToAnimation(float overTime = 0.1f) - Fully blends the skeleton's animation to use a predefined Unity animation clip. - Parameters: - overTime: The time in seconds over which to complete the blend (defaults to 0.1f). BlendTo(float blendToAmount, float overTime) - Allows manual control over blending between poser/animation data and skeleton input data. - Parameters: - blendToAmount: The amount to blend towards skeleton input data (0.0 for full poser/animation, 1.0 for full skeleton input). - overTime: The time in seconds over which to perform the blend. GetBone(int joint) - Returns the Transform of a specific bone identified by its joint index. - Parameters: - joint: The index of the bone (use SteamVR_Skeleton_JointIndexes enum). - Returns: The Transform of the requested bone. ForceToReferencePose(EVRSkeletalReferencePose referencePose) - Forces the skeleton's bones to adopt a specific reference pose, typically used for debugging. - Parameters: - referencePose: The type of reference pose to apply (e.g., `ReferencePose.Pose` or `ReferencePose.Reset`). Vector3[] GetBonePositions() - Retrieves an array containing the world-space positions of all bones. - Returns: An array of Vector3 representing bone positions. Quaternion[] GetBoneRotations() - Retrieves an array containing the world-space rotations of all bones. - Returns: An array of Quaternion representing bone rotations. ``` -------------------------------- ### SteamVR Behaviour Components Source: https://valvesoftware.github.io/steamvr_unity_plugin/articles/SteamVR-Input These Unity components handle common input tasks by abstracting device-specific details. Drag them onto a GameObject to utilize them for different action types. ```csharp SteamVR_Behaviour_Boolean SteamVR_Behaviour_Single SteamVR_Behaviour_Vector2 SteamVR_Behaviour_Vector3 SteamVR_Behaviour_Pose SteamVR_Behaviour_Skeleton ``` -------------------------------- ### Skeleton Input for Hand Tracking Source: https://valvesoftware.github.io/steamvr_unity_plugin/articles/intro Integrate skeletal hand data for advanced hand tracking. The SteamVR_Behaviour_Skeleton component processes raw skeletal data, providing joint positions and orientations for use with glove models or other hand visualizations. ```APIDOC SteamVR_Behaviour_Skeleton: Purpose: Processes and applies skeletal hand data from SteamVR to a GameObject. Usage: Attach to a GameObject to visualize skeletal hand tracking. Data Provided: - With Controller: Approximation of hand joints wrapped around the controller. - Without Controller: Estimation of hand openness/closedness based on controller data. Dependencies: Requires SteamVR Input and a tracked device with skeletal data support. Example: // Attach SteamVR_Behaviour_Skeleton to a GameObject with a glove model to animate it. // Example usage in a C# script: // public SteamVR_Behaviour_Skeleton skeletonSource; // void Update() { // // Access joint data via skeletonSource.skeletonData // // For example, to get the position of the wrist: // // Vector3 wristPosition = skeletonSource.skeletonData.joints[0].transform.position; // } ``` -------------------------------- ### SteamVR_Behaviour_Pose Component Usage Source: https://valvesoftware.github.io/steamvr_unity_plugin/articles/Render-Models Explains the role of the SteamVR_Behaviour_Pose component in setting the position and rotation of controller GameObjects. It is often used in conjunction with SteamVR_RenderModel. ```APIDOC SteamVR_Behaviour_Pose: Purpose: Sets the position and rotation of the GameObject it is attached to, typically representing a VR controller. Dependency: The GameObject with SteamVR_RenderModel must also have a component that sets its Index, such as SteamVR_Behaviour_Pose. ``` -------------------------------- ### SteamVR_Behaviour_Skeleton Events Source: https://valvesoftware.github.io/steamvr_unity_plugin/articles/Skeleton-Input Defines events that fire when specific skeleton updates or device status changes occur, supporting both UnityEvents and C# events. ```APIDOC SteamVR_Behaviour_Skeleton Events: onBoneTransformsUpdated - Fires after the skeleton's bone transforms have been updated. onTransformUpdated - Fires after the root transform of the skeleton GameObject has been updated. onTransformChanged - Fires when the root transform of the skeleton GameObject has been moved or rotated. onConnectedChanged - Fires whenever a VR device connected to this skeleton action is connected or disconnected. onTrackingChanged - Executes whenever the tracking state for the associated VR device changes. ``` -------------------------------- ### SteamVR_Behaviour_Skeleton Component Source: https://valvesoftware.github.io/steamvr_unity_plugin/api/index The SteamVR_Behaviour_Skeleton component utilizes SteamVR Skeleton Input to provide a best-guess approximation of hand joint positions. It can also orient the GameObject inline with the controller, potentially negating the need for a separate pose behaviour on the same object. Accuracy may vary based on the controller and tracking system. ```csharp // Attach this component to a GameObject to visualize hand skeleton data. // It can orient the GameObject to match the controller's orientation. ``` -------------------------------- ### SteamVR_RenderModel GetComponentTransform Method Source: https://valvesoftware.github.io/steamvr_unity_plugin/articles/Render-Models Provides a method to retrieve the Transform of a specific component on a controller model. This is useful for attaching other GameObjects to precise locations on the controller. ```APIDOC SteamVR_RenderModel.GetComponentTransform(string componentName): Description: Returns the Transform of a specified component on the controller model. Parameters: componentName (string): The case-sensitive name of the component to retrieve (e.g., "trigger", "grip"). Must match the hierarchy name at runtime. Returns: Transform: The Transform of the specified component. Notes: This method avoids garbage collection allocations. Ensure the componentName is exact, including capitalization. ``` -------------------------------- ### SteamVR_RenderModel Component Properties Source: https://valvesoftware.github.io/steamvr_unity_plugin/articles/Render-Models Details the configurable properties of the SteamVR_RenderModel component used for rendering virtual controller models in Unity. These properties allow customization of the model's appearance and behavior. ```APIDOC SteamVR_RenderModel: Index: Type: integer Description: The tracked device index for the controller, used by the render model system to identify the controller. This is essential for the component to function correctly. Model Override: Type: string (or reference to model asset) Description: Allows specifying a model to display instead of dynamically assessing the type of device connected. Primarily used for testing purposes. Shader: Type: Unity Shader reference Description: Enables specifying a different shader to render the model. Defaults to Unity's Standard Shader if not provided. Verbose: Type: boolean Description: When true, outputs debug logs to provide detailed information about the script's operations and status. Create Components: Type: boolean Description: If true, creates individual GameObjects for each component of the controller model where available, allowing for manipulation of specific parts. Update Dynamically: Type: boolean Description: If true, updates the position of individual controller components to match their physical counterparts in real-time. ``` -------------------------------- ### SteamVR_Behaviour_Pose Component Source: https://valvesoftware.github.io/steamvr_unity_plugin/api/index The SteamVR_Behaviour_Pose component is used to orient tracked objects in Unity. When attached to a GameObject, it automatically updates the transform's position and rotation to match a tracked object, such as VR controllers. It also provides access to velocity data and utility functions for orientation. ```csharp // Add this component to a GameObject to track a VR controller's pose. // Example: Attach to a GameObject representing the left controller. // The component will automatically update its transform to match the controller. ``` -------------------------------- ### Teleport Interaction Modifiers Source: https://valvesoftware.github.io/steamvr_unity_plugin/articles/Interaction-System Components that modify default teleport behavior, such as allowing teleportation while holding an object or passing the trace through specific objects. ```APIDOC Class: AllowTeleportWhileAttachedToHand Purpose: Bypasses the default restriction preventing teleportation when a hand has an object attached. Usage: - Add to an attached object to enable teleporting with that hand. - Used by objects like BlankController and longbow Arrow. Class: IgnoreTeleportTrace Purpose: Allows the teleport trace to pass through an object. Behavior: - Objects with this component do not block the teleport raycast. Alternative: - Place the object on a layer that the TeleportArc does not check against. Usage: - Applied to the longbow Arrow tip to allow the trace to pass through it. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.