Fix heads desyncing off bodies
This commit is contained in:
parent
0bcc31093c
commit
7cbcc1de96
11
Assets/Scripts/Networking/Packets/PlayerActionPckt.cs.meta
Normal file
11
Assets/Scripts/Networking/Packets/PlayerActionPckt.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ce4b9792bad15a54497d2a19cce83764
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -3,21 +3,22 @@ using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NeonTea.Quakeball.Util {
|
||||
/// <summary>Used to offset visual parts of violently re-synced objects, so they can be smoothly lerped back to reality.</summary>
|
||||
/// <summary>Used to offset visual parts of violently re-synced objects, so they can be smoothly lerped back to reality. This depends on the original localPosition staying the same.</summary>
|
||||
public class DesyncLerper : MonoBehaviour {
|
||||
public float Speed = 1;
|
||||
|
||||
private Vector3 OffsetLeft;
|
||||
private Vector3 OriginalLocalPosition;
|
||||
|
||||
public void Offset(Vector3 offset) {
|
||||
transform.position += offset;
|
||||
OffsetLeft += offset;
|
||||
}
|
||||
|
||||
private void Awake() {
|
||||
OriginalLocalPosition = transform.localPosition;
|
||||
}
|
||||
|
||||
private void Update() {
|
||||
Vector3 NewPosition = Vector3.Lerp(transform.position, transform.position - OffsetLeft, Speed * Time.deltaTime);
|
||||
OffsetLeft += NewPosition - transform.position;
|
||||
transform.position = NewPosition;
|
||||
transform.localPosition = Vector3.Lerp(transform.localPosition, OriginalLocalPosition, Speed * Time.deltaTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user