//IEnumerator CheckToDoAnim() //{ // yield return new WaitUntil(() => net.initialized); // yield return new WaitForFixedUpdate(); // if(net.IsOwner()) // { // StartCoroutine(HandleAnimationBoolPackets()); // } // yield return new WaitForFixedUpdate(); //} IEnumerator HandleAnimationBoolPackets() { while (NetServer.serverInstance != null || NetClient.instanceClient != null) { //Animation checking int index = 0; foreach (AnimatorControllerParameter parameter in animationBools) { if (anim.GetBool(parameter.name) != animationBoolsLastValue[index]) { bool value = anim.GetBool(parameter.name); animationBoolsLastValue[index] = value; net.UpdateField(parameter.name, value, true); //Debug.Log("Field Update Registered. " + parameter.name); } index += 1; } //SpriteRenderer flip checking if (manageSpriteFlips) { if (lastSpriteFlipXValue != sR.flipX) { net.UpdateField("SRFlipX", sR.flipX, true); lastSpriteFlipXValue = sR.flipX; } if (lastSpriteFlipYValue != sR.flipY) { net.UpdateField("SRFlipY", sR.flipY, true); lastSpriteFlipYValue = sR.flipY; } } yield return(new WaitForSeconds(1f / 25f)); } Debug.Log("Handle Animation Bool Packets has ended."); }
public bool[] CheckKey(NetworkObject myNet) { if (!isNetworked || myNet.IsOwner()) { bool newKeyDown = Input.GetKeyDown(key); bool newKeyPressed = Input.GetKey(key); bool newKeyUp = Input.GetKeyUp(key); if (isNetworked && (newKeyDown != keyDown || newKeyPressed != keyPressed || newKeyUp != keyUp)) { myNet.UpdateField("IW" + displayName, new KeyNetworkData(newKeyDown, newKeyPressed, newKeyUp), false); } keyDown = newKeyDown; keyPressed = newKeyPressed; keyUp = newKeyUp; } return(new bool[] { keyDown, keyPressed, keyUp }); }