Lean Tracking Overview

Lean Tracking APIs make it possible to incorporate player lean, how much their body is leaning from vertical, into their experience. You might use this feature to have a player lean around an obstacle to see something for instance. The value returned is pre-filtered for an optimum combination of stability and latency and packaged to resemble the thumbstick API.

Leaning left and right corresponds to X movement; leaning forward and back corresponds to Y movement. The values range between -1 and 1 in both drections, where 1 roughly corresponds to 45 degrees of lean.

Access the lean values in two ways:

Get the x and y lean values from the body frame

This code gets the x and y lean values from the body frame.

C++

IBody^ body = // get the body frame using NUI APIs;

Windows::Foundation::Point leanAmount = body->Lean;
float x = leanAmount.X;
float y = leanAmount.Y;

if(body->LeanTrackingState == TrackingState::Tracked)
{
  // do stuff with lean values
}
else
{
  // use values from previous frame or default values
}  

Get the x and y lean values from the body controller

This code gets the x and y lean values from the body controller.

C++

BodyController^ bodyController = // get the body controller

BodyControllerReading^ reading = pBodyController->GetCurrentReading();

float x = reading->LeanX;
float y = reading->LeanY;

if(reading->IsLeanTracked  == TRUE)
{
  // do stuff with lean values
}
else
{
  // use values from previous frame or default values
}