mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
This doesn't sync slow rotating objects (#428)
* This doesn't sync slow rotating objects The function sets lastRotation to the current rotation every frame, regardless of whether or not it detected a change. Because comparing two similar, but different Quaternions return true, only quickly rotating objects will return true; slow turning objects will return false, and the rotation will not be synced. By not updating lastRotation until a difference is spotted, any rotation will be synced. This fix allowed my slow rotating spaceship to sync rotation. TL;DR lastRotation should be the last time this function returned true, not the rotation last frame. * Update NetworkTransformBase.cs
This commit is contained in:
parent
f03e7b1ebe
commit
2b429c9b3a
@ -297,10 +297,16 @@ bool HasMovedOrRotated()
|
|||||||
bool rotated = lastRotation != targetComponent.transform.rotation;
|
bool rotated = lastRotation != targetComponent.transform.rotation;
|
||||||
|
|
||||||
// save last for next frame to compare
|
// save last for next frame to compare
|
||||||
|
// (only if change was detected. otherwise slow moving objects might
|
||||||
|
// never sync because of C#'s float comparison tolerance. see also:
|
||||||
|
// https://github.com/vis2k/Mirror/pull/428)
|
||||||
|
bool change = moved || rotated;
|
||||||
|
if (change)
|
||||||
|
{
|
||||||
lastPosition = targetComponent.transform.position;
|
lastPosition = targetComponent.transform.position;
|
||||||
lastRotation = targetComponent.transform.rotation;
|
lastRotation = targetComponent.transform.rotation;
|
||||||
|
}
|
||||||
return moved || rotated;
|
return change;
|
||||||
}
|
}
|
||||||
|
|
||||||
// set position carefully depending on the target component
|
// set position carefully depending on the target component
|
||||||
|
Loading…
Reference in New Issue
Block a user