Jaa


InteractionTracker.PositionVelocityInPixelsPerSecond Property

Definition

The velocity currently applied to position.

The PositionVelocityInPixelsPerSecond property represents the current position velocity of InteractionTracker while in Inertia. There are two main use cases for this property: Retrieving the position velocity of InteractionTracker right after an interaction has occurred or reference the most current velocity of InteractionTracker in an ExpressionAnimation.

public:
 property float3 PositionVelocityInPixelsPerSecond { float3 get(); };
float3 PositionVelocityInPixelsPerSecond();
public Vector3 PositionVelocityInPixelsPerSecond { get; }
var vector3 = interactionTracker.positionVelocityInPixelsPerSecond;
Public ReadOnly Property PositionVelocityInPixelsPerSecond As Vector3

Property Value

Vector3 Vector3

float3

The velocity currently applied to position.

Examples

// Listen for the InertiaStateEntered event, so we can grab PositionVelocityInPixelsPerSecond value.
public void InertiaStateEntered(InteractionTracker sender, InteractionTrackerInertiaStateEnteredArgs args)
{
  // Grab the current velocity of InteractionTracker after interaction occurs out of the args when the event is fired.
  Vector3 interactionVelocity = args.PositionVelocityInPixelsPerSecond;}
}

void CustomSpringMotion(float springCoefficient, float dampingCoefficient, float maxPosition)
{
  // Create the InertiaModifier that will be a custom motion emulating a spring
  InteractionTrackerInertiaMotion modifier = InteractionTrackerInertiaMotion.Create(_compositor);

  modifier.Condition = _compositor.CreateExpressionAnimation("this.Target.NaturalRestingPosition.X > maxPosition");
  modifier.Condition.SetScalarParameter("maxPosition", maxPosition);

  // Utilize the current Velocity of InteractionTracker in the Expression defining 	the custom spring motion
  modifier.Motion = _compositor.CreateExpressionAnimation("(-springStiffnessCoefficient * (this.Target.Position.X – maxPosition)) + (-dampingCoefficient * this.target.PositionVelocityInPixelsPerSecond.X");
  modifier.Motion.SetScalarParameter("springStiffnessCoefficient", 	springCoefficient);
  modifier.Motion.SetScalarParameter("dampingCoefficient", dampingCoefficient);
  modifier.Motion.SetScalarParameter("maxPosition", maxPosition); 
}

Remarks

When accessing the PositionVelocityInPixelsPerSecond property from the InertiaStateEntered event, you will be retrieving a snapshot of the calculated velocity based on the interaction. This event will only fire once after the interaction has occurred.

Applies to