{"_id":"5b1f93c009a1ad000391dd1d","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:34:56.985Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":10,"body":"> extends [VRTK_BaseGrabAttach](doc:vrtk_basegrabattach)\n\n## Overview\n\nScrubs through the given animation based on the distance from the grabbing object to the original grabbing point.\n\n**Script Usage:**\n * Place the `VRTK_ControlAnimationGrabAttach` 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   * Create and apply an animation via:\n     * `Animation Timeline` parameter takes a legacy `Animation` component to use as the timeline to scrub through. The animation must be marked as `legacy` via the inspector in debug mode.\n     * `Animator Timeline` parameter takes an Animator component to use as the timeline to scrub through.\n\n## Inspector Parameters\n\n * **Detach Distance:** The maximum distance the grabbing object is away from the Interactable Object before it is automatically released.\n * **Animation Timeline:** An Animation with the timeline to scrub through on grab. If this is set then the `Animator Timeline` will be ignored if it is also set.\n * **Animator Timeline:** An Animator with the timeline to scrub through on grab.\n * **Max Frames:** The maximum amount of frames in the timeline.\n * **Distance Multiplier:** An amount to multiply the distance by to determine the scrubbed frame to be on.\n * **Rewind On Release:** If this is checked then the animation will rewind to the start on ungrab.\n * **Rewind Speed Multplier:** The speed in which the animation rewind will be multiplied by.\n\n## Class Events\n\n * `AnimationFrameAtStart` - Emitted when the Animation Frame is at the start.\n * `AnimationFrameAtEnd` - Emitted when the Animation Frame is at the end.\n * `AnimationFrameChanged` - Emitted when the Animation Frame has changed.\n\n## Unity Events\n\nAdding the `VRTK_ControlAnimationGrabAttach_UnityEvents` component to `VRTK_ControlAnimationGrabAttach` 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 currentFrame` - The current frame the animation is on.\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### CreateTrackPoint/4\n\n  > `public override Transform CreateTrackPoint(Transform controllerPoint, GameObject currentGrabbedObject, GameObject currentGrabbingObject, ref bool customTrackPoint)`\n\n * Parameters\n   * `Transform controllerPoint` - The point on the controller where the grab was initiated.\n   * `GameObject currentGrabbedObject` - The GameObject that is currently being grabbed.\n   * `GameObject currentGrabbingObject` - The GameObject that is currently doing the grabbing.\n   * `ref bool customTrackPoint` - A reference to whether the created track point is an auto generated custom object.\n * Returns\n   * `Transform` - The Transform of the created track point.\n\nThe CreateTrackPoint method sets up the point of grab to track on the grabbed object.\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### SetFrame/1\n\n  > `public virtual void SetFrame(float frame)`\n\n * Parameters\n   * `float frame` - The frame to scrub to.\n * Returns\n   * _none_\n\nThe SetFrame method scrubs to the specific frame of the Animator timeline.\n\n### RewindAnimation/0\n\n  > `public virtual void RewindAnimation()`\n\n * Parameters\n   * _none_\n * Returns\n   * _none_\n\nThe RewindAnimation method will force the animation to rewind to the start frame.","excerpt":"","slug":"vrtk_controlanimationgrabattach","type":"basic","title":"VRTK_ControlAnimationGrabAttach"}

VRTK_ControlAnimationGrabAttach


> extends [VRTK_BaseGrabAttach](doc:vrtk_basegrabattach) ## Overview Scrubs through the given animation based on the distance from the grabbing object to the original grabbing point. **Script Usage:** * Place the `VRTK_ControlAnimationGrabAttach` 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. * Create and apply an animation via: * `Animation Timeline` parameter takes a legacy `Animation` component to use as the timeline to scrub through. The animation must be marked as `legacy` via the inspector in debug mode. * `Animator Timeline` parameter takes an Animator component to use as the timeline to scrub through. ## Inspector Parameters * **Detach Distance:** The maximum distance the grabbing object is away from the Interactable Object before it is automatically released. * **Animation Timeline:** An Animation with the timeline to scrub through on grab. If this is set then the `Animator Timeline` will be ignored if it is also set. * **Animator Timeline:** An Animator with the timeline to scrub through on grab. * **Max Frames:** The maximum amount of frames in the timeline. * **Distance Multiplier:** An amount to multiply the distance by to determine the scrubbed frame to be on. * **Rewind On Release:** If this is checked then the animation will rewind to the start on ungrab. * **Rewind Speed Multplier:** The speed in which the animation rewind will be multiplied by. ## Class Events * `AnimationFrameAtStart` - Emitted when the Animation Frame is at the start. * `AnimationFrameAtEnd` - Emitted when the Animation Frame is at the end. * `AnimationFrameChanged` - Emitted when the Animation Frame has changed. ## Unity Events Adding the `VRTK_ControlAnimationGrabAttach_UnityEvents` component to `VRTK_ControlAnimationGrabAttach` 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 currentFrame` - The current frame the animation is on. ## 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. ### CreateTrackPoint/4 > `public override Transform CreateTrackPoint(Transform controllerPoint, GameObject currentGrabbedObject, GameObject currentGrabbingObject, ref bool customTrackPoint)` * Parameters * `Transform controllerPoint` - The point on the controller where the grab was initiated. * `GameObject currentGrabbedObject` - The GameObject that is currently being grabbed. * `GameObject currentGrabbingObject` - The GameObject that is currently doing the grabbing. * `ref bool customTrackPoint` - A reference to whether the created track point is an auto generated custom object. * Returns * `Transform` - The Transform of the created track point. The CreateTrackPoint method sets up the point of grab to track on the grabbed object. ### ProcessUpdate/0 > `public override void ProcessUpdate()` * Parameters * _none_ * Returns * _none_ The ProcessUpdate method is run in every Update method on the Interactable Object. ### SetFrame/1 > `public virtual void SetFrame(float frame)` * Parameters * `float frame` - The frame to scrub to. * Returns * _none_ The SetFrame method scrubs to the specific frame of the Animator timeline. ### RewindAnimation/0 > `public virtual void RewindAnimation()` * Parameters * _none_ * Returns * _none_ The RewindAnimation method will force the animation to rewind to the start frame.