|
@@ -4,14 +4,45 @@ using UnityEngine;
|
|
|
|
|
|
public class SynchronizationObject : MonoBehaviour
|
|
|
{
|
|
|
+ public SyncObjectType type;
|
|
|
+
|
|
|
+ public bool isSync;
|
|
|
+
|
|
|
+ private SyncObject data;
|
|
|
+ private float Speed = 3;
|
|
|
+ private float framSpeed;
|
|
|
+ private float dis;
|
|
|
+ private float pross;
|
|
|
|
|
|
private void Start()
|
|
|
{
|
|
|
MultiPlayerManager.Instance.OnSynObject += OnSyncObject;
|
|
|
}
|
|
|
|
|
|
- private void OnSyncObject(SyncObject obj)
|
|
|
+ private void OnSyncObject(SyncObject data)
|
|
|
{
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void Update()
|
|
|
+ {
|
|
|
+ if(type == SyncObjectType.Player)
|
|
|
+ if (data != null && transform.position != data.pos)
|
|
|
+ {
|
|
|
+ framSpeed = Time.deltaTime * Speed;
|
|
|
+ dis = Vector3.Distance(transform.position, data.pos);
|
|
|
+ pross = 0;
|
|
|
+ if (framSpeed > dis)
|
|
|
+ {
|
|
|
+ transform.position = data.pos;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ pross = framSpeed / dis;
|
|
|
+ transform.position = Vector3.Lerp(transform.position, data.pos, pross);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|