Description
using UnityEngine;
using Volplane;
public class Demo : VolplaneBehaviour
{
public int playerId = 0; // Player identifier
public float trackingTime = 5f; // How long should the controller motion be tracked
private float time = 0f; // Time variable
private bool isTracking = false; // Flag
// Start receiving accelerometer and gyroscope input
public void StartTracking()
{
// Start tracking controller motion
TrackingControllerMotion(playerId, true);
time = 0f;
isTracking = true;
}
// Will be called every frame
void Update()
{
if(isTracking)
{
if(time >= trackingTime)
{
// Stop receiving motion data
TrackingControllerMotion(playerId, false);
isTracking = false;
}
else
{
time += Time.deltaTime;
}
}
}
}
Will tell a specified controller to start tracking device motion (accelerometer and gyroscope). For better processing performance, the Volplane framework will not receive motion input from the controllers unless explicitly stated.
Motion input can be handled by using the methods from the VInput class.
playerId | The player identifier. |
player | A player object. |
value | Boolean indicating the state, tracking (true) or not tracking (false). |