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

  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class PlayerNetworkBridge : MonoBehaviour {
  5. private Vector3 lastSentPos;
  6. public float moveIncrement = 0.01f;
  7. // Use this for initialization
  8. void Start () {
  9. SetPosition(Vector3.zero);
  10. }
  11. // Update is called once per frame
  12. void FixedUpdate () {
  13. if (Vector3.Distance(lastSentPos, transform.position) > moveIncrement)
  14. SetPosition(transform.position);
  15. }
  16. private void SetPosition(Vector3 position)
  17. {
  18. lastSentPos = position;
  19. Multiplayer.VectorMsg msg = new Multiplayer.VectorMsg(Multiplayer.ClientManager.Instance.ID, position);
  20. Multiplayer.ClientManager.Instance.SendMessage(Multiplayer.PlayerMsgID.Position, msg);
  21. }
  22. }