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

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