32 lines
798 B
C#
32 lines
798 B
C#
using FastArena.Network.Packets;
|
|
using UnityEngine;
|
|
|
|
namespace FastArena.Network
|
|
{
|
|
/// <summary>
|
|
/// Component fetching GameObject's Transform from the server every tick.
|
|
/// </summary>
|
|
public class SyncTransform : MonoBehaviour
|
|
{
|
|
public GameObjectId IdRef { get; private set; }
|
|
|
|
private void Start()
|
|
{
|
|
IdRef = GetComponent<GameObjectId>();
|
|
}
|
|
|
|
#if UNITY_SERVER
|
|
private void FixedUpdate()
|
|
{
|
|
Server.SendTransformUpdate(IdRef.Id, transform);
|
|
}
|
|
#else
|
|
internal void UpdateTransform(ref TransformUpdatePacket data)
|
|
{
|
|
transform.position = data.position;
|
|
transform.rotation = data.rotation;
|
|
}
|
|
#endif
|
|
}
|
|
}
|