Lier la vitesse du vélo à la vitesse de la vidéo

This commit is contained in:
Florent Guiotte 2018-03-10 17:49:54 +01:00
parent a8954747bd
commit aac6e1fac7
2 changed files with 12 additions and 2 deletions

View File

@ -19,13 +19,18 @@ public class BikeManager : MonoBehaviour {
private string inputID;
private float distancePerTick;
private float distanceRun;
private float normalSpeed;
private float Speed {get; set; }
private Queue<float> impulses = new Queue<float>();
private VideoManager vm;
// Use this for initialization
void Start () {
vm = gameObject.GetComponent<VideoManager>();
// TODO: Refactor w a player manager ?
switch (playerID) {
case 0:
@ -39,6 +44,8 @@ public class BikeManager : MonoBehaviour {
distancePerTick = wheelDiameter * Mathf.PI / ticPerTurn;
Debug.Log("Distance to run:" + distanceToRun);
Debug.Log("Distance per tick:" + distancePerTick);
normalSpeed = distanceToRun / vm.raceFinishTime;
}
// Update is called once per frame
@ -49,6 +56,8 @@ public class BikeManager : MonoBehaviour {
Speed = getBikeSpeed(speedIntegrationTime);
Debug.Log(Speed);
vm.speed = Speed / normalSpeed;
}
int getBikeImpulses(float timeWindow = .5f) {

View File

@ -6,10 +6,11 @@ using UnityEngine.Video;
public class VideoManager : MonoBehaviour {
private VideoPlayer videoPlayer;
private float speed {get; set; }
public float speed {get; set; }
public float raceFinishTime = 30.0f;
void Start () {
speed = 1.0f;
speed = 0.0f;
videoPlayer = gameObject.AddComponent<VideoPlayer>();
// TODO: Aspect Ratio is not working?
videoPlayer.aspectRatio = VideoAspectRatio.FitOutside;