Share via


InteractionTracker.TryUpdatePositionWithAdditionalVelocity(Vector3) Method

Definition

Tries to update the InteractionTracker's position by adding velocity.

The TryUpdatePositionWithAdditionalVelocity method adds the input Vector3 representing additional velocity to the current velocity of InteractionTracker. As a result, because the velocity of InteractionTracker has now changed, the targeted rest position for InteractionTracker now changes. TryUpdatePositionWithAdditionalVelocity can be called from either Idle, Inertia or CustomAnimation states – doing so will either add or update the velocity of InteractionTracker and enter the Inertia state.

public:
 virtual int TryUpdatePositionWithAdditionalVelocity(float3 velocityInPixelsPerSecond) = TryUpdatePositionWithAdditionalVelocity;
int TryUpdatePositionWithAdditionalVelocity(float3 const& velocityInPixelsPerSecond);
public int TryUpdatePositionWithAdditionalVelocity(Vector3 velocityInPixelsPerSecond);
function tryUpdatePositionWithAdditionalVelocity(velocityInPixelsPerSecond)
Public Function TryUpdatePositionWithAdditionalVelocity (velocityInPixelsPerSecond As Vector3) As Integer

Parameters

velocityInPixelsPerSecond
Vector3 Vector3

float3

The velocity to add in pixels per second.

Returns

Int32

int

Returns the request ID. On state transitions, the request which caused the change in state will be included in the args. These IDs will start at 1 and increase with each try call during the lifetime of the application.

Examples

// Listen for the InertiaStateEntered event
public void InertiaStateEntered(InteractionTracker sender, 	InteractionTrackerInertiaStateEnteredArgs args)
{
  // Adding velocity to InteractionTracker if condition met
  if (_extraVelocityNeeded)
  {
    // Only adding velocity in the Y direction
    _tracker.TryUpdatePositionWithAdditionalVelocity(new Vector3(0.0f, 50.0f,	0.0f));
  }
}

Remarks

If InteractionTracker is in its Interacting State (user actively manipulating), and TryUpdatePositionWithAdditionalVelocity is called, the system will ignore this request – an event gets fired when this occurs that can be listened for. If sent from one of the other states, listen for the event fired for InertiaStateEntered and check the RequestId property that identifies which request triggered the callback. The table below summarizes the expected behavior when this method is called in a particular state:

Current StateOutcome
IdleState changes to inertia and inertia modifiers are evaluated with requested velocity as initial velocity
InteractingRequest ignored
InertiaInertia is restarted (state re-enters inertia) and inertia modifiers are evaluated with requested velocity added to current velocity
CustomAnimationCurrent animation stops and state changes to inertia with inertia modifiers evaluated using requested velocity as initial velocity

Applies to