Skip to content

Commit c7323a3

Browse files
committed
feat(Interaction): add artificial rotator controllable
The Artificial Rotator is a simulated rotator that uses no Unity physics to rotate an object. It utilises the Rotate Transform Grab Mechanic and simulates as much as the Physics Rotator control as possible but without the need for joints or rigidbodies.
1 parent 6f8af98 commit c7323a3

File tree

8 files changed

+2367
-3770
lines changed

8 files changed

+2367
-3770
lines changed

Assets/VRTK/Documentation/API.md

Lines changed: 155 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -6558,6 +6558,7 @@ The GetControlInteractableObject method returns the Interactable Object associat
65586558
A collection of scripts that provide artificial simulated controls that mimiic real life objects.
65596559

65606560
* [Artificial Pusher](#artificial-pusher-vrtk_artificialpusher)
6561+
* [Artificial Rotator](#artificial-rotator-vrtk_artificialrotator)
65616562

65626563
---
65636564

@@ -6642,6 +6643,160 @@ The SetPositionTarget method sets the `Position Target` parameter to the given n
66426643

66436644
---
66446645

6646+
## Artificial Rotator (VRTK_ArtificialRotator)
6647+
> extends [VRTK_BaseControllable](#base-controllable-vrtk_basecontrollable)
6648+
6649+
### Overview
6650+
6651+
A artificially simulated openable rotator.
6652+
6653+
**Required Components:**
6654+
* `Collider` - A Unity Collider to determine when an interaction has occured. Can be a compound collider set in child GameObjects. Will be automatically added at runtime.
6655+
6656+
**Script Usage:**
6657+
* Create a rotator container GameObject and set the GameObject that is to become the rotator as a child of the newly created container GameObject.
6658+
* Place the `VRTK_ArtificialRotator` script onto the GameObject that is to become the rotatable object and ensure the Transform rotation is `0, 0, 0`.
6659+
* Create a nested GameObject under the rotator GameObject and position it where the hinge should operate.
6660+
* Apply the nested hinge GameObject to the `Hinge Point` parameter on the Artificial Rotator script.
6661+
6662+
> The rotator GameObject must not be at the root level and needs to have the Transform rotation set to `0,0,0`. This is the reason for the container GameObject requirement. Any positioning of the rotator must be set on the parent container GameObject.
6663+
> The Artificial Rotator script GameObject will become the child of a runtime created GameObject that determines the rotational offset for the rotator.
6664+
6665+
### Inspector Parameters
6666+
6667+
* **Hinge Point:** A Transform that denotes the position where the rotator will rotate around.
6668+
* **Minimum Angle:** The minimum angle the rotator can rotate to.
6669+
* **Maximum Angle:** The maximum angle the rotator can rotate to.
6670+
* **Min Max Threshold Angle:** The angle at which the rotator rotation can be within the minimum or maximum angle before the minimum or maximum angles are considered reached.
6671+
* **Resting Angle:** The angle at which will be considered as the resting position of the rotator.
6672+
* **Force Resting Angle Threshold:** The threshold angle from the `Resting Angle` that the current angle of the rotator needs to be within to snap the rotator back to the `Resting Angle`.
6673+
* **Is Locked:** If this is checked then the rotator Rigidbody will have all rotations frozen.
6674+
* **Step Value Range:** The minimum `(x)` and the maximum `(y)` step values for the rotator to register along the `Operate Axis`.
6675+
* **Step Size:** The increments the rotator value will change in between the `Step Value Range`.
6676+
* **Use Step As Value:** If this is checked then the value for the rotator will be the step value and not the absolute rotation of the rotator Transform.
6677+
* **Snap To Step:** If this is checked then the rotator will snap to the angle of the nearest step along the value range.
6678+
* **Snap Force:** The speed in which the rotator will snap to the relevant angle along the `Operate Axis`
6679+
* **Precision Grab:** If this is checked then when the Interact Grab grabs the Interactable Object, it will grab it with precision and pick it up at the particular point on the Interactable Object that the Interact Touch is touching.
6680+
* **Detach Distance:** The maximum distance the grabbing object is away from the rotator before it is automatically released.
6681+
* **Rotation Action:** Determines how the rotation of the object is calculated based on the action of the grabbing object.
6682+
* **Grabbed Friction:** The simulated friction when the rotator is grabbed.
6683+
* **Released Friction:** The simulated friction when the rotator is released.
6684+
* **Only Interact With:** A collection of GameObjects that will be used as the valid collisions to determine if the rotator can be interacted with.
6685+
6686+
### Class Methods
6687+
6688+
#### GetValue/0
6689+
6690+
> `public override float GetValue()`
6691+
6692+
* Parameters
6693+
* _none_
6694+
* Returns
6695+
* `float` - The actual rotation of the rotator.
6696+
6697+
The GetValue method returns the current rotation value of the rotator.
6698+
6699+
#### GetNormalizedValue/0
6700+
6701+
> `public override float GetNormalizedValue()`
6702+
6703+
* Parameters
6704+
* _none_
6705+
* Returns
6706+
* `float` - The normalized rotation of the rotator.
6707+
6708+
The GetNormalizedValue method returns the current rotation value of the rotator normalized between `0f` and `1f`.
6709+
6710+
#### GetContainer/0
6711+
6712+
> `public virtual GameObject GetContainer()`
6713+
6714+
* Parameters
6715+
* _none_
6716+
* Returns
6717+
* `GameObject` - The GameObject container of the rotator control.
6718+
6719+
The GetContainer method returns the GameObject that is generated to hold the rotator control.
6720+
6721+
#### GetStepValue/1
6722+
6723+
> `public virtual float GetStepValue(float currentValue)`
6724+
6725+
* Parameters
6726+
* `float currentValue` - The current angle value of the rotator to get the Step Value for.
6727+
* Returns
6728+
* `float` - The current Step Value based on the rotator angle.
6729+
6730+
The GetStepValue method returns the current angle of the rotator based on the step value range.
6731+
6732+
#### SetAngleTargetWithStepValue/1
6733+
6734+
> `public virtual void SetAngleTargetWithStepValue(float givenStepValue)`
6735+
6736+
* Parameters
6737+
* `float givenStepValue` - The step value within the `Step Value Range` to set the `Angle Target` parameter to.
6738+
* Returns
6739+
* _none_
6740+
6741+
The SetAngleTargetWithStepValue sets the `Angle Target` parameter but uses a value within the `Step Value Range`.
6742+
6743+
#### SetRestingAngleWithStepValue/1
6744+
6745+
> `public virtual void SetRestingAngleWithStepValue(float givenStepValue)`
6746+
6747+
* Parameters
6748+
* `float givenStepValue` - The step value within the `Step Value Range` to set the `Resting Angle` parameter to.
6749+
* Returns
6750+
* _none_
6751+
6752+
The SetRestingAngleWithStepValue sets the `Resting Angle` parameter but uses a value within the `Step Value Range`.
6753+
6754+
#### GetAngleFromStepValue/1
6755+
6756+
> `public virtual float GetAngleFromStepValue(float givenStepValue)`
6757+
6758+
* Parameters
6759+
* `float givenStepValue` - The step value to check the angle for.
6760+
* Returns
6761+
* `float` - The angle the rotator would be at based on the given step value.
6762+
6763+
The GetAngleFromStepValue returns the angle the rotator would be at based on the given step value.
6764+
6765+
#### SetAngleTarget/1
6766+
6767+
> `public virtual void SetAngleTarget(float newAngle)`
6768+
6769+
* Parameters
6770+
* `float newAngle` - The angle in which to rotate the rotator to.
6771+
* Returns
6772+
* _none_
6773+
6774+
The SetAngleTarget method sets a target angle to rotate the rotator to.
6775+
6776+
#### IsResting/0
6777+
6778+
> `public override bool IsResting()`
6779+
6780+
* Parameters
6781+
* _none_
6782+
* Returns
6783+
* `bool` - Returns `true` if the rotator is at the resting angle or within the resting angle threshold.
6784+
6785+
The IsResting method returns whether the rotator is at the resting angle or within the resting angle threshold.
6786+
6787+
#### GetControlInteractableObject/0
6788+
6789+
> `public virtual VRTK_InteractableObject GetControlInteractableObject()`
6790+
6791+
* Parameters
6792+
* _none_
6793+
* Returns
6794+
* `VRTK_InteractableObject` - The Interactable Object associated with the control.
6795+
6796+
The GetControlInteractableObject method returns the Interactable Object associated with the control.
6797+
6798+
---
6799+
66456800
# Presence (VRTK/Source/Scripts/Presence)
66466801

66476802
A collection of scripts that provide the ability to deal with tracking the world around the user in the scene.
@@ -7561,7 +7716,6 @@ All 3D controls extend the `VRTK_Control` abstract class which provides common m
75617716

75627717
* [Control](#control-vrtk_control)
75637718
* [Drawer](#drawer-vrtk_drawer)
7564-
* [Wheel](#wheel-vrtk_wheel)
75657719
* [Slider](#slider-vrtk_slider)
75667720
* [Content Handler](#content-handler-vrtk_contenthandler)
75677721

@@ -7679,41 +7833,6 @@ It is possible to supply a third game object which is the root of the contents i
76797833

76807834
---
76817835

7682-
## Wheel (VRTK_Wheel)
7683-
> extends [VRTK_Control](#control-vrtk_control)
7684-
7685-
### Overview
7686-
7687-
Attaching the script to a game object will allow the user to interact with it as if it were a spinnable wheel.
7688-
7689-
The script will instantiate the required Rigidbody and Interactable components automatically in case they do not exist yet.
7690-
7691-
### Inspector Parameters
7692-
7693-
* **Connected To:** An optional game object to which the wheel will be connected. If the game object moves the wheel will follow along.
7694-
* **Grab Type:** The grab attach mechanic to use. Track Object allows for rotations of the controller, Rotator Track allows for grabbing the wheel and spinning it.
7695-
* **Detatch Distance:** The maximum distance the grabbing controller is away from the wheel before it is automatically released.
7696-
* **Minimum Value:** The minimum value the wheel can be set to.
7697-
* **Maximum Value:** The maximum value the wheel can be set to.
7698-
* **Step Size:** The increments in which values can change.
7699-
* **Snap To Step:** If this is checked then when the wheel is released, it will snap to the step rotation.
7700-
* **Grabbed Friction:** The amount of friction the wheel will have when it is grabbed.
7701-
* **Released Friction:** The amount of friction the wheel will have when it is released.
7702-
* **Max Angle:** The maximum angle the wheel has to be turned to reach it's maximum value.
7703-
* **Lock At Limits:** If this is checked then the wheel cannot be turned beyond the minimum and maximum value.
7704-
7705-
### Class Variables
7706-
7707-
* `public enum GrabTypes` - The grab attach mechanic to use.
7708-
* `TrackObject` - Utilise the track object grab mechanic.
7709-
* `RotatorTrack` - Utilise the rotator track grab mechanic.
7710-
7711-
### Example
7712-
7713-
`VRTK/Examples/025_Controls_Overview` has a collection of wheels that can be rotated by grabbing with the controller and then rotating the controller in the desired direction.
7714-
7715-
---
7716-
77177836
## Slider (VRTK_Slider)
77187837
> extends [VRTK_Control](#control-vrtk_control)
77197838

0 commit comments

Comments
 (0)