Tacos indépendant entre la vidéo et le HUD
This commit is contained in:
parent
4c07152b23
commit
a7d9d63164
@ -50,7 +50,7 @@ public class BikeManager : MonoBehaviour {
|
||||
void Update () {
|
||||
if (taco.GetDistanceRun() < distanceToRun) {
|
||||
Speed = taco.GetSpeed();
|
||||
vm.speed = Speed / normalSpeed;
|
||||
//vm.speed = Speed / normalSpeed;
|
||||
} else {
|
||||
// Player finished
|
||||
vm.speed = 1f;
|
||||
|
@ -9,7 +9,7 @@ public class RAWTachometer : Tachometer {
|
||||
|
||||
public override float GetSpeed() {
|
||||
int c = impulses.Count(i => i > Time.time - delta);
|
||||
return c * distancePerTick;
|
||||
return c * distancePerTick / delta;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ public abstract class Tachometer : MonoBehaviour {
|
||||
|
||||
// Process
|
||||
protected float distancePerTick;
|
||||
protected float normalSpeed;
|
||||
|
||||
protected List<float> impulses = new List<float>();
|
||||
|
||||
@ -32,6 +33,7 @@ public abstract class Tachometer : MonoBehaviour {
|
||||
Debug.Log("Diameter: " + wheelDiameter);
|
||||
|
||||
distancePerTick = wheelDiameter * Mathf.PI / ticPerTurn;
|
||||
normalSpeed = gm.GetRaceDistance() / gm.GetRaceNormalTime();
|
||||
}
|
||||
|
||||
private void RegisterTic() {
|
||||
@ -42,6 +44,10 @@ public abstract class Tachometer : MonoBehaviour {
|
||||
return -1f;
|
||||
}
|
||||
|
||||
public float GetPlayerSpeed() {
|
||||
return GetSpeed () / normalSpeed;
|
||||
}
|
||||
|
||||
public float GetDistanceRun() {
|
||||
return distancePerTick * impulses.Count();
|
||||
}
|
||||
|
@ -9,6 +9,8 @@ public class VideoManager : MonoBehaviour {
|
||||
public float speed {get; set; }
|
||||
public bool setUp = false;
|
||||
|
||||
private Tachometer taco;
|
||||
|
||||
private int skinID;
|
||||
|
||||
public void SetSkin(int playerID) {
|
||||
@ -16,6 +18,9 @@ public class VideoManager : MonoBehaviour {
|
||||
|
||||
var gm = GameManager.Instance;
|
||||
|
||||
taco = gameObject.AddComponent<RAWTachometer>();
|
||||
taco.SetPlayer (playerID);
|
||||
|
||||
skinID = gm.GetSkins(playerID);
|
||||
videoPlayer.url = Application.streamingAssetsPath + "/" + skinID + ".webm";
|
||||
|
||||
@ -48,6 +53,6 @@ public class VideoManager : MonoBehaviour {
|
||||
}
|
||||
|
||||
void Update () {
|
||||
videoPlayer.playbackSpeed = speed;
|
||||
videoPlayer.playbackSpeed = taco.GetPlayerSpeed();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user