fix: properly detect NT rotation (#1516)

This commit is contained in:
Paul Pacheco 2020-02-23 13:46:06 -06:00 committed by GitHub
parent caab56d2fb
commit f0a993c106
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -36,7 +36,7 @@ public abstract class NetworkTransformBase : NetworkBehaviour
[Header("Sensitivity")] [Header("Sensitivity")]
[Tooltip("Changes to the transform must exceed these values to be transmitted on the network.")] [Tooltip("Changes to the transform must exceed these values to be transmitted on the network.")]
public float localPositionSensitivity = .01f; public float localPositionSensitivity = .01f;
[Tooltip("Changes to the transform must exceed these values to be transmitted on the network.")] [Tooltip("If rotation exceeds this angle, it will be transmitted on the network")]
public float localRotationSensitivity = .01f; public float localRotationSensitivity = .01f;
[Tooltip("Changes to the transform must exceed these values to be transmitted on the network.")] [Tooltip("Changes to the transform must exceed these values to be transmitted on the network.")]
public float localScaleSensitivity = .01f; public float localScaleSensitivity = .01f;
@ -344,8 +344,8 @@ bool HasEitherMovedRotatedScaled()
// moved or rotated or scaled? // moved or rotated or scaled?
// local position/rotation/scale for VR support // local position/rotation/scale for VR support
bool moved = Vector3.Distance(lastPosition, targetComponent.transform.localPosition) > localPositionSensitivity; bool moved = Vector3.Distance(lastPosition, targetComponent.transform.localPosition) > localPositionSensitivity;
bool rotated = Vector3.Distance(lastRotation.eulerAngles, targetComponent.transform.localRotation.eulerAngles) > localRotationSensitivity;
bool scaled = Vector3.Distance(lastScale, targetComponent.transform.localScale) > localScaleSensitivity; bool scaled = Vector3.Distance(lastScale, targetComponent.transform.localScale) > localScaleSensitivity;
bool rotated = Quaternion.Angle(lastRotation, targetComponent.transform.localRotation) > localRotationSensitivity;
// save last for next frame to compare // save last for next frame to compare
// (only if change was detected. otherwise slow moving objects might // (only if change was detected. otherwise slow moving objects might