Lier la vitesse du vélo à la vitesse de la vidéo
This commit is contained in:
parent
a8954747bd
commit
aac6e1fac7
@ -19,13 +19,18 @@ public class BikeManager : MonoBehaviour {
|
|||||||
private string inputID;
|
private string inputID;
|
||||||
private float distancePerTick;
|
private float distancePerTick;
|
||||||
private float distanceRun;
|
private float distanceRun;
|
||||||
|
private float normalSpeed;
|
||||||
|
|
||||||
private float Speed {get; set; }
|
private float Speed {get; set; }
|
||||||
|
|
||||||
private Queue<float> impulses = new Queue<float>();
|
private Queue<float> impulses = new Queue<float>();
|
||||||
|
|
||||||
|
private VideoManager vm;
|
||||||
|
|
||||||
// Use this for initialization
|
// Use this for initialization
|
||||||
void Start () {
|
void Start () {
|
||||||
|
vm = gameObject.GetComponent<VideoManager>();
|
||||||
|
|
||||||
// TODO: Refactor w a player manager ?
|
// TODO: Refactor w a player manager ?
|
||||||
switch (playerID) {
|
switch (playerID) {
|
||||||
case 0:
|
case 0:
|
||||||
@ -39,6 +44,8 @@ public class BikeManager : MonoBehaviour {
|
|||||||
distancePerTick = wheelDiameter * Mathf.PI / ticPerTurn;
|
distancePerTick = wheelDiameter * Mathf.PI / ticPerTurn;
|
||||||
Debug.Log("Distance to run:" + distanceToRun);
|
Debug.Log("Distance to run:" + distanceToRun);
|
||||||
Debug.Log("Distance per tick:" + distancePerTick);
|
Debug.Log("Distance per tick:" + distancePerTick);
|
||||||
|
|
||||||
|
normalSpeed = distanceToRun / vm.raceFinishTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
@ -49,6 +56,8 @@ public class BikeManager : MonoBehaviour {
|
|||||||
|
|
||||||
Speed = getBikeSpeed(speedIntegrationTime);
|
Speed = getBikeSpeed(speedIntegrationTime);
|
||||||
Debug.Log(Speed);
|
Debug.Log(Speed);
|
||||||
|
|
||||||
|
vm.speed = Speed / normalSpeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getBikeImpulses(float timeWindow = .5f) {
|
int getBikeImpulses(float timeWindow = .5f) {
|
||||||
|
|||||||
@ -6,10 +6,11 @@ using UnityEngine.Video;
|
|||||||
public class VideoManager : MonoBehaviour {
|
public class VideoManager : MonoBehaviour {
|
||||||
|
|
||||||
private VideoPlayer videoPlayer;
|
private VideoPlayer videoPlayer;
|
||||||
private float speed {get; set; }
|
public float speed {get; set; }
|
||||||
|
public float raceFinishTime = 30.0f;
|
||||||
|
|
||||||
void Start () {
|
void Start () {
|
||||||
speed = 1.0f;
|
speed = 0.0f;
|
||||||
videoPlayer = gameObject.AddComponent<VideoPlayer>();
|
videoPlayer = gameObject.AddComponent<VideoPlayer>();
|
||||||
// TODO: Aspect Ratio is not working?
|
// TODO: Aspect Ratio is not working?
|
||||||
videoPlayer.aspectRatio = VideoAspectRatio.FitOutside;
|
videoPlayer.aspectRatio = VideoAspectRatio.FitOutside;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user