private void Start() { Application.runInBackground = true; Client = this; //TODO: Move Send/Translate UDP/TCP to EN_Protocol // It shouldn't bother the Unity code, really. }
public static EN_Client Contact() { if (Client == null) { Client = FindObjectOfType <EN_Client>(); } return(Client); }
private void Send() { Vector3 pos = transform.position; Vector3 rot = transform.rotation.eulerAngles; Vector3 vel = (transform.position - lastpos).normalized * Vector3.Distance(transform.position, lastpos); velocity = vel; EN_PacketTransform data; data.packet_type = EN_UDP_PACKET_TYPE.TRANSFORM; data.packet_network_id = instanceID; data.tX = pos.x; data.tY = pos.y; data.tZ = pos.z; data.rX = rot.x; data.rY = rot.y; data.rZ = rot.z; data.vX = vel.x; data.vY = vel.y; data.vZ = vel.z; EN_Client.Contact().SendUDP(data); }