Fixed issues with lag compensation
This commit is contained in:
parent
b680126866
commit
a24588e6a7
@ -18,17 +18,18 @@ namespace MLAPI.MonoBehaviours.Core
|
|||||||
savedPosition = transform.position;
|
savedPosition = transform.position;
|
||||||
savedRotation = transform.rotation;
|
savedRotation = transform.rotation;
|
||||||
float currentTime = Time.time;
|
float currentTime = Time.time;
|
||||||
float targetTime = Time.time - secondsAgo;
|
float targetTime = currentTime - secondsAgo;
|
||||||
float previousTime = 0;
|
float previousTime = 0;
|
||||||
float nextTime = 0;
|
float nextTime = 0;
|
||||||
for (int i = 1; i < Framekeys.Count - 1; i++)
|
for (int i = 1; i < Framekeys.Count; i++)
|
||||||
{
|
{
|
||||||
if(Framekeys[i - 1] > targetTime && Framekeys[i] <= targetTime)
|
if (Framekeys[i - 1] <= targetTime && Framekeys[i] >= targetTime)
|
||||||
{
|
{
|
||||||
previousTime = Framekeys[i];
|
previousTime = Framekeys[i];
|
||||||
nextTime = Framekeys[i + 1];
|
nextTime = Framekeys[i + 1];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float timeBetweenFrames = nextTime - previousTime;
|
float timeBetweenFrames = nextTime - previousTime;
|
||||||
@ -59,7 +60,7 @@ namespace MLAPI.MonoBehaviours.Core
|
|||||||
float currentTime = Time.time;
|
float currentTime = Time.time;
|
||||||
for (int i = 0; i < Framekeys.Count; i++)
|
for (int i = 0; i < Framekeys.Count; i++)
|
||||||
{
|
{
|
||||||
if (currentTime - Framekeys[i] <= NetworkingManager.singleton.NetworkConfig.SecondsHistory)
|
if (currentTime - Framekeys[i] >= NetworkingManager.singleton.NetworkConfig.SecondsHistory)
|
||||||
{
|
{
|
||||||
for (int j = 0; j < i; j++)
|
for (int j = 0; j < i; j++)
|
||||||
{
|
{
|
||||||
@ -74,7 +75,7 @@ namespace MLAPI.MonoBehaviours.Core
|
|||||||
position = transform.position,
|
position = transform.position,
|
||||||
rotation = transform.rotation
|
rotation = transform.rotation
|
||||||
});
|
});
|
||||||
Framekeys.Add(Time.frameCount);
|
Framekeys.Add(Time.time);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user