not needed?
This commit is contained in:
parent
f506425f17
commit
a34545ae26
|
@ -16,10 +16,6 @@ public class MyNetworkPlayer : NetworkBehaviour
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
private Color _playerColor = Color.black;
|
private Color _playerColor = Color.black;
|
||||||
|
|
||||||
[SyncVar(hook = nameof(UpdateTransform))]
|
|
||||||
[SerializeField]
|
|
||||||
private Transform _transform;
|
|
||||||
|
|
||||||
[Server]
|
[Server]
|
||||||
public void SetDisplayName(string newDisplayName)
|
public void SetDisplayName(string newDisplayName)
|
||||||
{
|
{
|
||||||
|
@ -47,29 +43,4 @@ public class MyNetworkPlayer : NetworkBehaviour
|
||||||
_playerNameObject.color = newColor;
|
_playerNameObject.color = newColor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnConnectedToServer()
|
|
||||||
{
|
|
||||||
BindTransform();
|
|
||||||
}
|
|
||||||
|
|
||||||
[Server]
|
|
||||||
private void BindTransform()
|
|
||||||
{
|
|
||||||
_transform = transform;
|
|
||||||
}
|
|
||||||
|
|
||||||
[Server]
|
|
||||||
private void UpdateTransform(Transform oldValue, Transform newValue)
|
|
||||||
{
|
|
||||||
var cachedTransform = transform;
|
|
||||||
cachedTransform.position = newValue.position;
|
|
||||||
cachedTransform.rotation = newValue.rotation;
|
|
||||||
}
|
|
||||||
|
|
||||||
[Client]
|
|
||||||
private void Update()
|
|
||||||
{
|
|
||||||
_transform = transform;
|
|
||||||
}
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue