{"_id":"5b1f94213073470003ffa736","project":"571fa55ca0acd42000af9545","version":{"_id":"5b1f8576c2505d00031254db","project":"571fa55ca0acd42000af9545","__v":4,"forked_from":"594949e52be16d0026ec04cd","createdAt":"2017-06-20T16:14:29.816Z","releaseDate":"2017-06-20T16:14:29.816Z","categories":["5b1f8576c2505d0003125424","5b1f8576c2505d0003125425","5b1f8576c2505d0003125426","5b1f8576c2505d0003125427","5b1f8576c2505d0003125428","5b1f8576c2505d0003125429","5b1f8576c2505d000312542a","5b1f8576c2505d000312542b","5b1f8576c2505d000312542c","5b1f8576c2505d000312542d","5b1f8576c2505d000312542e","5b1f8576c2505d000312542f","5b1f8576c2505d0003125430","5b1f8576c2505d0003125431","5b1f8576c2505d0003125432","5b1f8576c2505d0003125433","5b1f8576c2505d0003125434","5b1f8576c2505d0003125435","5b1f8576c2505d0003125436","5b1f8576c2505d0003125437","5b1f8576c2505d0003125438","5b1f8aab9c683000032979e7","5b1f8b2f3073470003ffa5da","5b1f8bd9fd653400031d94f4","5b1f900bd4c5f000036b57bd"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"Mangalica","version_clean":"3.3.0","version":"3.3.0"},"category":{"_id":"5b1f8576c2505d000312542c","version":"5b1f8576c2505d00031254db","project":"571fa55ca0acd42000af9545","__v":0,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2017-01-01T16:50:06.279Z","from_sync":false,"order":9,"slug":"grab-attach-mechanics","title":"Grab Attach Mechanics"},"user":"571fa519db52d01700f5cf3d","githubsync":"","__v":0,"parentDoc":null,"updates":[],"next":{"pages":[],"description":""},"createdAt":"2018-06-12T09:36:33.243Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":12,"body":"> extends [VRTK_BaseGrabAttach](doc:vrtk_basegrabattach)\n\n## Overview\n\nRotates the Transform of the Interactable Object around a specified transform local axis within the given limits.\n\n  > To allow unrestricted movement, set the angle limits minimum to `-infinity` and the angle limits maximum to `infinity`.\n\n**Script Usage:**\n * Place the `VRTK_RotateTransformGrabAttach` script on either:\n   * The GameObject of the Interactable Object to detect interactions on.\n   * Any other scene GameObject and then link that GameObject to the Interactable Objects `Grab Attach Mechanic Script` parameter to denote use of the grab mechanic.\n\n## Inspector Parameters\n\n * **Detach Distance:** The maximum distance the grabbing object is away from the Interactable Object before it is automatically dropped.\n * **Origin Deadzone:** The distance between grabbing object and the centre of Interactable Object that is considered to be non grabbable. If the grabbing object is within the `Origin Deadzone` distance then it will be automatically ungrabbed.\n * **Rotate Around:** The local axis in which to rotate the object around.\n * **Rotation Action:** Determines how the rotation of the object is calculated based on the action of the grabbing object.\n * **Rotation Friction:** The amount of friction to apply when rotating, simulates a tougher rotation.\n * **Release Deceleration Damper:** The damper in which to slow the Interactable Object's rotation down when released to simulate continued momentum. The higher the number, the faster the Interactable Object will come to a complete stop on release.\n * **Reset To Orign On Release Speed:** The speed in which the Interactable Object returns to it's origin rotation when released. If the `Reset To Orign On Release Speed` is `0f` then the rotation will not be reset.\n * **Angle Limits:** The negative and positive limits the axis can be rotated to.\n * **Min Max Threshold:** The threshold the rotation value needs to be within to register a min or max rotation value.\n * **Min Max Normalized Threshold:** The threshold the normalized rotation value needs to be within to register a min or max normalized rotation value.\n\n## Class Variables\n\n * `public enum RotationAxis` - The local axis for rotation.\n   * `xAxis` - The local X Axis of the transform.\n   * `yAxis` - The local Y Axis of the transform.\n   * `zAxis` - The local Z Axis of the transform.\n * `public enum RotationType` - The way in which rotation from the grabbing object is applied.\n   * `FollowAttachPoint` - The angle between the Interactable Object origin and the grabbing object attach point.\n   * `FollowLongitudinalAxis` - The angular velocity across the grabbing object's longitudinal axis (the roll axis).\n   * `FollowLateralAxis` - The angular velocity across the grabbing object's lateral axis (the pitch axis).\n   * `FollowPerpendicularAxis` - The angular velocity across the grabbing object's perpendicular axis (the yaw axis).\n * `public Quaternion originRotation` - The default local rotation of the Interactable Object.\n\n## Class Events\n\n * `AngleChanged` - Emitted when the angle changes.\n * `MinAngleReached` - Emitted when the angle reaches the minimum angle.\n * `MinAngleExited` - Emitted when the angle exits the minimum angle state.\n * `MaxAngleReached` - Emitted when the angle reaches the maximum angle.\n * `MaxAngleExited` - Emitted when the angle exits the maximum angle state.\n\n## Unity Events\n\nAdding the `VRTK_RotateTransformGrabAttach_UnityEvents` component to `VRTK_RotateTransformGrabAttach` object allows access to `UnityEvents` that will react identically to the Class Events.\n\n * All C# delegate events are mapped to a Unity Event with the `On` prefix. e.g. `MyEvent` -> `OnMyEvent`.\n\n## Event Payload\n\n * `GameObject interactingObject` - The GameObject that is performing the interaction (e.g. a controller).\n * `float currentAngle` - The current angle the Interactable Object is rotated to.\n * `float normalizedAngle` - The normalized angle (between `0f` and `1f`) the Interactable Object is rotated to.\n * `Vector3 rotationSpeed` - The speed in which the rotation is occuring.\n\n## Class Methods\n\n### StartGrab/3\n\n  > `public override bool StartGrab(GameObject grabbingObject, GameObject givenGrabbedObject, Rigidbody givenControllerAttachPoint)`\n\n * Parameters\n   * `GameObject grabbingObject` - The GameObject that is doing the grabbing.\n   * `GameObject givenGrabbedObject` - The GameObject that is being grabbed.\n   * `Rigidbody givenControllerAttachPoint` - The point on the grabbing object that the grabbed object should be attached to after grab occurs.\n * Returns\n   * `bool` - Returns `true` if the grab is successful, `false` if the grab is unsuccessful.\n\nThe StartGrab method sets up the grab attach mechanic as soon as an Interactable Object is grabbed.\n\n### StopGrab/1\n\n  > `public override void StopGrab(bool applyGrabbingObjectVelocity)`\n\n * Parameters\n   * `bool applyGrabbingObjectVelocity` - If `true` will apply the current velocity of the grabbing object to the grabbed object on release.\n * Returns\n   * _none_\n\nThe StopGrab method ends the grab of the current Interactable Object and cleans up the state.\n\n### ProcessUpdate/0\n\n  > `public override void ProcessUpdate()`\n\n * Parameters\n   * _none_\n * Returns\n   * _none_\n\nThe ProcessUpdate method is run in every Update method on the Interactable Object.\n\n### SetRotation/2\n\n  > `public virtual void SetRotation(float newAngle, float transitionTime = 0f)`\n\n * Parameters\n   * `float newAngle` - The angle to rotate to through the current rotation axis.\n   * `float transitionTime` - The time in which the entire rotation operation will take place.\n * Returns\n   * _none_\n\nThe SetRotation method sets the rotation on the Interactable Object to the given angle over the desired time.\n\n### ResetRotation/1\n\n  > `public virtual void ResetRotation(bool ignoreTransition = false)`\n\n * Parameters\n   * `bool ignoreTransition` - If this is `true` then the `Reset To Origin On Release Speed` will be ignored and the reset will occur instantly.\n * Returns\n   * _none_\n\nThe ResetRotation method will rotate the Interactable Object back to the origin rotation.\n\n### GetAngle/0\n\n  > `public virtual float GetAngle()`\n\n * Parameters\n   * _none_\n * Returns\n   * `float` - The current rotated angle.\n\nThe GetAngle method returns the current angle the Interactable Object is rotated to.\n\n### GetNormalizedAngle/0\n\n  > `public virtual float GetNormalizedAngle()`\n\n * Parameters\n   * _none_\n * Returns\n   * `float` - The normalized rotated angle. Will return `0f` if either limit is set to `infinity`.\n\nThe GetNormalizedAngle returns the normalized current angle between the minimum and maximum angle limits.\n\n### GetRotationSpeed/0\n\n  > `public virtual Vector3 GetRotationSpeed()`\n\n * Parameters\n   * _none_\n * Returns\n   * `Vector3` - A Vector3 containing the speed each axis is rotating in.\n\nThe GetRotationSpeed returns the current speed in which the Interactable Object is rotating.","excerpt":"","slug":"vrtk_rotatetransformgrabattach","type":"basic","title":"VRTK_RotateTransformGrabAttach"}

VRTK_RotateTransformGrabAttach


> extends [VRTK_BaseGrabAttach](doc:vrtk_basegrabattach) ## Overview Rotates the Transform of the Interactable Object around a specified transform local axis within the given limits. > To allow unrestricted movement, set the angle limits minimum to `-infinity` and the angle limits maximum to `infinity`. **Script Usage:** * Place the `VRTK_RotateTransformGrabAttach` script on either: * The GameObject of the Interactable Object to detect interactions on. * Any other scene GameObject and then link that GameObject to the Interactable Objects `Grab Attach Mechanic Script` parameter to denote use of the grab mechanic. ## Inspector Parameters * **Detach Distance:** The maximum distance the grabbing object is away from the Interactable Object before it is automatically dropped. * **Origin Deadzone:** The distance between grabbing object and the centre of Interactable Object that is considered to be non grabbable. If the grabbing object is within the `Origin Deadzone` distance then it will be automatically ungrabbed. * **Rotate Around:** The local axis in which to rotate the object around. * **Rotation Action:** Determines how the rotation of the object is calculated based on the action of the grabbing object. * **Rotation Friction:** The amount of friction to apply when rotating, simulates a tougher rotation. * **Release Deceleration Damper:** The damper in which to slow the Interactable Object's rotation down when released to simulate continued momentum. The higher the number, the faster the Interactable Object will come to a complete stop on release. * **Reset To Orign On Release Speed:** The speed in which the Interactable Object returns to it's origin rotation when released. If the `Reset To Orign On Release Speed` is `0f` then the rotation will not be reset. * **Angle Limits:** The negative and positive limits the axis can be rotated to. * **Min Max Threshold:** The threshold the rotation value needs to be within to register a min or max rotation value. * **Min Max Normalized Threshold:** The threshold the normalized rotation value needs to be within to register a min or max normalized rotation value. ## Class Variables * `public enum RotationAxis` - The local axis for rotation. * `xAxis` - The local X Axis of the transform. * `yAxis` - The local Y Axis of the transform. * `zAxis` - The local Z Axis of the transform. * `public enum RotationType` - The way in which rotation from the grabbing object is applied. * `FollowAttachPoint` - The angle between the Interactable Object origin and the grabbing object attach point. * `FollowLongitudinalAxis` - The angular velocity across the grabbing object's longitudinal axis (the roll axis). * `FollowLateralAxis` - The angular velocity across the grabbing object's lateral axis (the pitch axis). * `FollowPerpendicularAxis` - The angular velocity across the grabbing object's perpendicular axis (the yaw axis). * `public Quaternion originRotation` - The default local rotation of the Interactable Object. ## Class Events * `AngleChanged` - Emitted when the angle changes. * `MinAngleReached` - Emitted when the angle reaches the minimum angle. * `MinAngleExited` - Emitted when the angle exits the minimum angle state. * `MaxAngleReached` - Emitted when the angle reaches the maximum angle. * `MaxAngleExited` - Emitted when the angle exits the maximum angle state. ## Unity Events Adding the `VRTK_RotateTransformGrabAttach_UnityEvents` component to `VRTK_RotateTransformGrabAttach` object allows access to `UnityEvents` that will react identically to the Class Events. * All C# delegate events are mapped to a Unity Event with the `On` prefix. e.g. `MyEvent` -> `OnMyEvent`. ## Event Payload * `GameObject interactingObject` - The GameObject that is performing the interaction (e.g. a controller). * `float currentAngle` - The current angle the Interactable Object is rotated to. * `float normalizedAngle` - The normalized angle (between `0f` and `1f`) the Interactable Object is rotated to. * `Vector3 rotationSpeed` - The speed in which the rotation is occuring. ## Class Methods ### StartGrab/3 > `public override bool StartGrab(GameObject grabbingObject, GameObject givenGrabbedObject, Rigidbody givenControllerAttachPoint)` * Parameters * `GameObject grabbingObject` - The GameObject that is doing the grabbing. * `GameObject givenGrabbedObject` - The GameObject that is being grabbed. * `Rigidbody givenControllerAttachPoint` - The point on the grabbing object that the grabbed object should be attached to after grab occurs. * Returns * `bool` - Returns `true` if the grab is successful, `false` if the grab is unsuccessful. The StartGrab method sets up the grab attach mechanic as soon as an Interactable Object is grabbed. ### StopGrab/1 > `public override void StopGrab(bool applyGrabbingObjectVelocity)` * Parameters * `bool applyGrabbingObjectVelocity` - If `true` will apply the current velocity of the grabbing object to the grabbed object on release. * Returns * _none_ The StopGrab method ends the grab of the current Interactable Object and cleans up the state. ### ProcessUpdate/0 > `public override void ProcessUpdate()` * Parameters * _none_ * Returns * _none_ The ProcessUpdate method is run in every Update method on the Interactable Object. ### SetRotation/2 > `public virtual void SetRotation(float newAngle, float transitionTime = 0f)` * Parameters * `float newAngle` - The angle to rotate to through the current rotation axis. * `float transitionTime` - The time in which the entire rotation operation will take place. * Returns * _none_ The SetRotation method sets the rotation on the Interactable Object to the given angle over the desired time. ### ResetRotation/1 > `public virtual void ResetRotation(bool ignoreTransition = false)` * Parameters * `bool ignoreTransition` - If this is `true` then the `Reset To Origin On Release Speed` will be ignored and the reset will occur instantly. * Returns * _none_ The ResetRotation method will rotate the Interactable Object back to the origin rotation. ### GetAngle/0 > `public virtual float GetAngle()` * Parameters * _none_ * Returns * `float` - The current rotated angle. The GetAngle method returns the current angle the Interactable Object is rotated to. ### GetNormalizedAngle/0 > `public virtual float GetNormalizedAngle()` * Parameters * _none_ * Returns * `float` - The normalized rotated angle. Will return `0f` if either limit is set to `infinity`. The GetNormalizedAngle returns the normalized current angle between the minimum and maximum angle limits. ### GetRotationSpeed/0 > `public virtual Vector3 GetRotationSpeed()` * Parameters * _none_ * Returns * `Vector3` - A Vector3 containing the speed each axis is rotating in. The GetRotationSpeed returns the current speed in which the Interactable Object is rotating.