HoverUnlock() public method

Stop hovering over this object indefinitely.
public HoverUnlock ( VRInteractable interactable ) : void
interactable VRInteractable The hover-locked VRInteractable to stop hovering over indefinitely.
return void
	/// <summary>
	/// Called every Update() while a VRHand is hovering over me.
	/// </summary>
	/// <param name="hand"></param>
	void HandHoverUpdate( VRHand hand )
	{
		if ( hand.GetStandardInteractionButtonDown() || ( ( hand.controller != null ) && hand.controller.GetPressDown( Valve.VR.EVRButtonId.k_EButton_Grip ) ) )
		{
			if ( hand.currentAttachedObject != gameObject )
			{
				// Save our position/rotation so that we can restore it when we detach
				oldPosition = transform.position;
				oldRotation = transform.rotation;

				// Call this to continue receiving HandHoverUpdate messages,
				// and prevent the hand from hovering over anything else
				hand.HoverLock( GetComponent<VRInteractable>() );

				// Attach this object to the hand
				hand.AttachObject( gameObject, false );
			}
			else
			{
				// Detach this object from the hand
				hand.DetachObject( gameObject );

				// Call this to undo HoverLock
				hand.HoverUnlock( GetComponent<VRInteractable>() );

				// Restore position/rotation
				transform.position = oldPosition;
				transform.rotation = oldRotation;
			}
		}
	}
Exemplo n.º 2
0
    /// <summary>
    /// Called every Update() while a VRHand is hovering over me.
    /// </summary>
    /// <param name="hand"></param>
    void HandHoverUpdate(VRHand hand)
    {
        if (hand.GetStandardInteractionButtonDown() || ((hand.controller != null) && hand.controller.GetPressDown(Valve.VR.EVRButtonId.k_EButton_Grip)))
        {
            if (hand.currentAttachedObject != gameObject)
            {
                // Save our position/rotation so that we can restore it when we detach
                oldPosition = transform.position;
                oldRotation = transform.rotation;

                // Call this to continue receiving HandHoverUpdate messages,
                // and prevent the hand from hovering over anything else
                hand.HoverLock(GetComponent <VRInteractable>());

                // Attach this object to the hand
                hand.AttachObject(gameObject, attachmentFlags);
            }
            else
            {
                // Detach this object from the hand
                hand.DetachObject(gameObject);

                // Call this to undo HoverLock
                hand.HoverUnlock(GetComponent <VRInteractable>());

                // Restore position/rotation
                transform.position = oldPosition;
                transform.rotation = oldRotation;
            }
        }
    }
Exemplo n.º 3
0
    void OnDetachedFromHand(VRHand hand)
    {
        attached = false;

        hand.HoverUnlock(null);

        Rigidbody rb = GetComponent <Rigidbody>();

        rb.isKinematic   = false;
        rb.interpolation = RigidbodyInterpolation.Interpolate;

        velocityEstimator.FinishEstimatingVelocity();
        Vector3 velocity        = velocityEstimator.GetVelocityEstimate();
        Vector3 angularVelocity = velocityEstimator.GetAngularVelocityEstimate();

        rb.velocity        = velocity;
        rb.angularVelocity = angularVelocity;

        // Make the object travel at the release velocity for the amount
        // of time it will take until the next fixed update, at which
        // point Unity physics will take over
        float timeUntilFixedUpdate = (Time.fixedDeltaTime + Time.fixedTime) - Time.time;

        transform.position += timeUntilFixedUpdate * velocity;
        float   angle = Mathf.Rad2Deg * angularVelocity.magnitude;
        Vector3 axis  = angularVelocity.normalized;

        transform.rotation *= Quaternion.AngleAxis(angle * timeUntilFixedUpdate, axis);
    }
Exemplo n.º 4
0
    void OnDetachedFromHand( VRHand hand )
    {
        attached = false;

        hand.HoverUnlock( null );

        Rigidbody rb = GetComponent<Rigidbody>();
        rb.isKinematic = false;
        rb.interpolation = RigidbodyInterpolation.Interpolate;

        velocityEstimator.FinishEstimatingVelocity();
        rb.velocity = velocityEstimator.GetVelocityEstimate();
        rb.angularVelocity = velocityEstimator.GetAngularVelocityEstimate();
    }
Exemplo n.º 5
0
    void OnDetachedFromHand(VRHand hand)
    {
        attached = false;

        hand.HoverUnlock(null);

        Rigidbody rb = GetComponent <Rigidbody>();

        rb.isKinematic   = false;
        rb.interpolation = RigidbodyInterpolation.Interpolate;

        velocityEstimator.FinishEstimatingVelocity();
        rb.velocity        = velocityEstimator.GetVelocityEstimate();
        rb.angularVelocity = velocityEstimator.GetAngularVelocityEstimate();
    }
Exemplo n.º 6
0
    void HandHoverUpdate( VRHand hand )
    {
        if ( hand.currentAttachedObject )
            return;

        if ( hand.GetStandardInteractionButtonDown() )
        {
            hand.HoverLock( GetComponent<VRInteractable>() );
        }

        if ( hand.GetStandardInteractionButtonUp() )
        {
            hand.HoverUnlock( GetComponent<VRInteractable>() );
        }

        if ( hand.GetStandardInteractionButton() )
        {
            UpdateLinearMapping( hand.transform );
        }
    }
Exemplo n.º 7
0
    void HandHoverUpdate(VRHand hand)
    {
        if (hand.currentAttachedObject)
        {
            return;
        }

        if (hand.GetStandardInteractionButtonDown())
        {
            hand.HoverLock(GetComponent <VRInteractable>());
        }

        if (hand.GetStandardInteractionButtonUp())
        {
            hand.HoverUnlock(GetComponent <VRInteractable>());
        }

        if (hand.GetStandardInteractionButton())
        {
            UpdateLinearMapping(hand.transform);
        }
    }
	void HandHoverUpdate( VRHand hand )
	{
		if ( hand.GetStandardInteractionButtonDown() )
		{
			hand.HoverLock( GetComponent<VRInteractable>() );

			initialMappingOffset = linearMapping.value - CalculateLinearMapping( hand.transform );
			sampleCount = 0;
			mappingChangeRate = 0.0f;
		}

		if ( hand.GetStandardInteractionButtonUp() )
		{
			hand.HoverUnlock( GetComponent<VRInteractable>() );

			CalculateMappingChangeRate();
		}

		if ( hand.GetStandardInteractionButton() )
		{
			UpdateLinearMapping( hand.transform );
		}
	}
    void HandHoverUpdate(VRHand hand)
    {
        if (hand.GetStandardInteractionButtonDown())
        {
            hand.HoverLock(GetComponent <VRInteractable>());

            initialMappingOffset = linearMapping.value - CalculateLinearMapping(hand.transform);
            sampleCount          = 0;
            mappingChangeRate    = 0.0f;
        }

        if (hand.GetStandardInteractionButtonUp())
        {
            hand.HoverUnlock(GetComponent <VRInteractable>());

            CalculateMappingChangeRate();
        }

        if (hand.GetStandardInteractionButton())
        {
            UpdateLinearMapping(hand.transform);
        }
    }
Exemplo n.º 10
0
	void OnDetachedFromHand( VRHand hand )
	{
		attached = false;

		hand.HoverUnlock( null );

		Rigidbody rb = GetComponent<Rigidbody>();
		rb.isKinematic = false;
		rb.interpolation = RigidbodyInterpolation.Interpolate;

		velocityEstimator.FinishEstimatingVelocity();
		Vector3 velocity = velocityEstimator.GetVelocityEstimate();
		Vector3 angularVelocity = velocityEstimator.GetAngularVelocityEstimate();
		rb.velocity = velocity;
		rb.angularVelocity = angularVelocity;

		// Make the object travel at the release velocity for the amount
		// of time it will take until the next fixed update, at which
		// point physics will happily take over simulation
		float t = ( Time.fixedDeltaTime + Time.fixedTime ) - Time.time;
		transform.position += t * velocity;
		// TODO: update transform.rotation? probably too subtle, but should be fixed
		// TODO: verify the fix using large fixed timestep, determine if the warning should be deleted
	}
	void OnDetachedFromHand( VRHand hand )
	{
		attached = false;

		hand.HoverUnlock( null );

		Rigidbody rb = GetComponent<Rigidbody>();
		rb.isKinematic = false;
		rb.interpolation = RigidbodyInterpolation.Interpolate;

		velocityEstimator.FinishEstimatingVelocity();
		Vector3 velocity = velocityEstimator.GetVelocityEstimate();
		Vector3 angularVelocity = velocityEstimator.GetAngularVelocityEstimate();
		rb.velocity = velocity;
		rb.angularVelocity = angularVelocity;

		// Make the object travel at the release velocity for the amount
		// of time it will take until the next fixed update, at which
		// point Unity physics will take over
		float timeUntilFixedUpdate = ( Time.fixedDeltaTime + Time.fixedTime ) - Time.time;
		transform.position += timeUntilFixedUpdate * velocity;
		float angle = Mathf.Rad2Deg * angularVelocity.magnitude;
		Vector3 axis = angularVelocity.normalized;
		transform.rotation *= Quaternion.AngleAxis( angle * timeUntilFixedUpdate, axis );
	}