mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
NetworkTransformUnreliable: UpdateClientInterpolation helper function
This commit is contained in:
parent
6e142d8cc0
commit
5f1ec83cca
@ -227,6 +227,26 @@ void UpdateClientBroadcast()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UpdateClientInterpolation()
|
||||||
|
{
|
||||||
|
// only while we have snapshots
|
||||||
|
if (clientSnapshots.Count > 0)
|
||||||
|
{
|
||||||
|
// step the interpolation without touching time.
|
||||||
|
// NetworkClient is responsible for time globally.
|
||||||
|
SnapshotInterpolation.StepInterpolation(
|
||||||
|
clientSnapshots,
|
||||||
|
NetworkTime.time, // == NetworkClient.localTimeline from snapshot interpolation
|
||||||
|
out TransformSnapshot from,
|
||||||
|
out TransformSnapshot to,
|
||||||
|
out double t);
|
||||||
|
|
||||||
|
// interpolate & apply
|
||||||
|
TransformSnapshot computed = TransformSnapshot.Interpolate(from, to, t);
|
||||||
|
Apply(computed, to);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void UpdateClient()
|
void UpdateClient()
|
||||||
{
|
{
|
||||||
// client authority, and local player (= allowed to move myself)?
|
// client authority, and local player (= allowed to move myself)?
|
||||||
@ -238,22 +258,7 @@ void UpdateClient()
|
|||||||
// we need to apply snapshots from the buffer
|
// we need to apply snapshots from the buffer
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// only while we have snapshots
|
UpdateClientInterpolation();
|
||||||
if (clientSnapshots.Count > 0)
|
|
||||||
{
|
|
||||||
// step the interpolation without touching time.
|
|
||||||
// NetworkClient is responsible for time globally.
|
|
||||||
SnapshotInterpolation.StepInterpolation(
|
|
||||||
clientSnapshots,
|
|
||||||
NetworkTime.time, // == NetworkClient.localTimeline from snapshot interpolation
|
|
||||||
out TransformSnapshot from,
|
|
||||||
out TransformSnapshot to,
|
|
||||||
out double t);
|
|
||||||
|
|
||||||
// interpolate & apply
|
|
||||||
TransformSnapshot computed = TransformSnapshot.Interpolate(from, to, t);
|
|
||||||
Apply(computed, to);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user