Scrubs through the given animation based on the distance from the grabbing object to the original grabbing point.
- Place the
VRTK_ControlAnimationGrabAttachscript 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 Scriptparameter to denote use of the grab mechanic.
- Create and apply an animation via:
Animation Timelineparameter takes a legacy
Animationcomponent to use as the timeline to scrub through. The animation must be marked as
legacyvia the inspector in debug mode.
Animator Timelineparameter takes an Animator component to use as the timeline to scrub through.
- 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 Timelinewill 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.
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.
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
GameObject interactingObject- The GameObject that is performing the interaction (e.g. a controller).
float currentFrame- The current frame the animation is on.
public override bool StartGrab(GameObject grabbingObject, GameObject givenGrabbedObject, Rigidbody givenControllerAttachPoint)
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.
trueif the grab is successful,
falseif the grab is unsuccessful.
The StartGrab method sets up the grab attach mechanic as soon as an Interactable Object is grabbed.
public override void StopGrab(bool applyGrabbingObjectVelocity)
bool applyGrabbingObjectVelocity- If
truewill apply the current velocity of the grabbing object to the grabbed object on release.
The StopGrab method ends the grab of the current Interactable Object and cleans up the state.
public override Transform CreateTrackPoint(Transform controllerPoint, GameObject currentGrabbedObject, GameObject currentGrabbingObject, ref bool customTrackPoint)
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.
Transform- The Transform of the created track point.
The CreateTrackPoint method sets up the point of grab to track on the grabbed object.
public override void ProcessUpdate()
The ProcessUpdate method is run in every Update method on the Interactable Object.
public virtual void SetFrame(float frame)
float frame- The frame to scrub to.
The SetFrame method scrubs to the specific frame of the Animator timeline.
public virtual void RewindAnimation()
The RewindAnimation method will force the animation to rewind to the start frame.
Updated less than a minute ago