public Interactable hoveringInteractable
{
get { return _hoveringInteractable; }
set
{
if (_hoveringInteractable != value)
{
if (_hoveringInteractable != null)
{
if (spewDebugText)
HandDebugLog("HoverEnd " + _hoveringInteractable.gameObject);
_hoveringInteractable.SendMessage("OnHandHoverEnd", this, SendMessageOptions.DontRequireReceiver);
//Note: The _hoveringInteractable can change after sending the OnHandHoverEnd message so we need to check it again before broadcasting this message
if (_hoveringInteractable != null)
{
this.BroadcastMessage("OnParentHandHoverEnd", _hoveringInteractable, SendMessageOptions.DontRequireReceiver); // let objects attached to the hand know that a hover has ended
}
}
_hoveringInteractable = value;
if (_hoveringInteractable != null)
{
if (spewDebugText)
HandDebugLog("HoverBegin " + _hoveringInteractable.gameObject);
_hoveringInteractable.SendMessage("OnHandHoverBegin", this, SendMessageOptions.DontRequireReceiver);
//Note: The _hoveringInteractable can change after sending the OnHandHoverBegin message so we need to check it again before broadcasting this message
if (_hoveringInteractable != null)
{
this.BroadcastMessage("OnParentHandHoverBegin", _hoveringInteractable, SendMessageOptions.DontRequireReceiver); // let objects attached to the hand know that a hover has begun
}
}
}
}
}
2)、 如图4所示,勾选Show Right Preview 即对手势进行编辑,此时可以看到在物体的附近有一个手的模型,如果想在模板的基础上编辑可以选择Reference Pose:选择之后手即可变成模板的样子。该手部编辑模型会作为子物体出现在,
但是紧紧时在编辑模式下出现,作为编辑使用,编辑完之后需要取消 Show Right Preview的勾选方可正常显示和使用。
直接调整手的位置和关键,使其达到符合要求的握住物体的样子即可,然后勾选Show Left Preview此时下面的Copy Left pose to Right Hand和Copy Right pose to Right Hand会被激活。注意:因为刚刚编辑的时Right的,因此点右边下面的Copy Left pose to Right Hand按钮,将右边的镜像处理得到 左边的数据并覆盖当前左边的,点击之后即可看到两只手都以同样的姿势握住物体。这里一定要点对,不然前面的工作会被覆盖而需要重新做。最后,点击Save Pose 即可。
protected virtual void HandAttachedUpdate(Hand hand)
{
if (hand.IsGrabEnding(this.gameObject))
{
hand.DetachObject(gameObject, restoreOriginalParent);
// Uncomment to detach ourselves late in the frame.
// This is so that any vehicles the player is attached to
// have a chance to finish updating themselves.
// If we detach now, our position could be behind what it
// will be at the end of the frame, and the object may appear
// to teleport behind the hand when the player releases it.
//StartCoroutine( LateDetach( hand ) );
}
if (onHeldUpdate != null)
onHeldUpdate.Invoke(hand);
}
private void HandAttachedUpdate( Hand hand )
{
...
// If arrow is nocked, and we release the trigger
if ( nocked && hand.IsGrabbingWithType(nockedWithType) == false )
{
if ( bow.pulled ) // If bow is pulled back far enough, fire arrow, otherwise reset arrow in arrowhand
{
FireArrow();
}
else
{
arrowNockTransform.rotation = currentArrow.transform.rotation;
currentArrow.transform.parent = arrowNockTransform;
Util.ResetTransform( currentArrow.transform );
nocked = false;
nockedWithType = GrabTypes.None;
bow.ReleaseNock();
hand.HoverUnlock( GetComponent<Interactable>() );
allowTeleport.teleportAllowed = true;
}
bow.StartRotationLerp(); // Arrow is releasing from the bow, tell the bow to lerp back to controller rotation
}
}