You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

30 lines
788 B

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);
}
}