Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
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 is 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 directions, where 1 roughly corresponds to 45 degrees of lean.
Access the lean values from the body frame.
Get the X and Y lean values from the body frame
This code gets the X and Y lean values from the body frame.
IBody^ body = // Gets 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.
}