using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerNetworkBridge : MonoBehaviour {

    private Vector3 lastSentPos;

    public float moveIncrement = 0.01f;


	// Use this for initialization
	void Start () {
        SetPosition(Vector3.zero);
	}
	
	// Update is called once per frame
	void FixedUpdate () {
        if (Vector3.Distance(lastSentPos, transform.position) > moveIncrement)
            SetPosition(transform.position);
	}

    private void SetPosition(Vector3 position)
    {
        lastSentPos = position;

        Multiplayer.VectorMsg msg = new Multiplayer.VectorMsg(Multiplayer.ClientManager.Instance.ID, position);
        Multiplayer.ClientManager.Instance.SendMessage(Multiplayer.PlayerMsgID.Position, msg);
    }
}