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
762 B

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TestPlayerScript : MonoBehaviour {
private Vector3 lastSentPos;
public float moveIncrement = 0.01f;
// Use this for initialization
void Start () {
SendPosition();
}
// Update is called once per frame
void FixedUpdate () {
if (Vector3.Distance(lastSentPos, transform.position) > moveIncrement)
SendPosition();
}
private void SendPosition()
{
lastSentPos = transform.position;
Multiplayer.VectorMsg msg = new Multiplayer.VectorMsg(Multiplayer.ClientManager.Instance.ID, transform.position);
Multiplayer.ClientManager.Instance.SendMessage(Multiplayer.PlayerMsgID.Position, msg);
}
}