private void Update() { if (isDead) { return; } if (waitForStart) { playerBase.PlayIdleAnim(); if (Input.GetKeyDown(KeyCode.Space)) { waitForStart = false; } } else { if (IsGrounded() && Input.GetKeyDown(KeyCode.Space)) { float jumpVelocity = 100f; rigidbody2d.velocity = Vector2.up * jumpVelocity; OSCHandler.Instance.SendMessageToClient("pd", "/unity/jump", 1); } addSpeed = GameObject.Find("LevelGenerator").GetComponent <LevelGenerator>().speed; HandleMovement(addSpeed); // Set Animations if (IsGrounded()) { if (rigidbody2d.velocity.x == 0) { playerBase.PlayIdleAnim(); } else { playerBase.PlayMoveAnim(new Vector2(rigidbody2d.velocity.x, 0f)); } } else { playerBase.PlayJumpAnim(rigidbody2d.velocity); } } //OSCHandler.Instance.OnPacketReceived("unity", packets); OSCHandler.Instance.UpdateLogs(); //Debug.Log(OSCHandler.Instance.packets); //OSCReciever.getNextMessage(); Dictionary <string, ClientLog> clients = new Dictionary <string, ClientLog>(); clients = OSCHandler.Instance.Clients; Dictionary <string, ServerLog> servers = new Dictionary <string, ServerLog>(); servers = OSCHandler.Instance.Servers; //Debug.Log(servers); foreach (KeyValuePair <string, ServerLog> author in servers) { Debug.Log(author.Value); } }
private void Update() { if (isDead) { return; } if (IsGrounded()) { if (Input.GetKeyDown(KeyCode.Space) || Input.GetKeyDown(KeyCode.UpArrow)) { float jumpVelocity = 100f; rigidbody2d.velocity = Vector2.up * jumpVelocity; } } HandleMovement(); // Set Animations if (IsGrounded()) { if (rigidbody2d.velocity.x == 0) { playerBase.PlayIdleAnim(); } else { playerBase.PlayMoveAnim(new Vector2(rigidbody2d.velocity.x, 0f)); } } else { playerBase.PlayJumpAnim(rigidbody2d.velocity); } if (rigidbody2d.velocity.y < -300f) { // Falling way too fast, dead Die(); } }