void Update() { //Respawn player if (Input.GetKeyDown(KeyCode.R)) { BeginKillPlayer(); } //Player movement velocityx = +accelerationx *Input.GetAxis("Horizontal"); if (Mathf.Abs(velocityx) > speed) { velocityx = speed * Input.GetAxis("Horizontal"); } if (!isjumpedin && rb.gravityScale == 3.5) { transform.position = transform.position + new Vector3(velocityx * Time.deltaTime, 0, 0); } //Player jumping if (IsGrounded() && Input.GetKeyDown(KeyCode.Space)) { rb.velocity = Vector2.up * jumpVelo; } else if (hasRejump && Input.GetKeyDown(KeyCode.Space)) { hasRejump = false; rb.velocity = Vector2.up * jumpVelo; } if (IsGrounded()) { refreshJump(); } //? relic of old game /*else if (Input.GetKeyDown(KeyCode.DownArrow)) * { * rb.velocity = (Vector2.up * jumpVelo * -1); * }*/ //Jump in and out functionality if (canjumpin && Input.GetKeyDown(KeyCode.DownArrow)) { this.gameObject.transform.localScale = new Vector3(0, 0, 0); isjumpedin = true; currentHealth += 15; } else if (canjumpinmv && Input.GetKeyDown(KeyCode.DownArrow)) { this.gameObject.transform.localScale = new Vector3(0, 0, 0); isjumpedinmv = true; currentHealth += 15; } if (isjumpedin) { transform.position = intObj.transform.position; } else if (isjumpedinmv) { intObj.transform.position = new Vector3(this.transform.position.x, intObj.transform.position.y, intObj.transform.position.z); } if (isjumpedin && Input.GetKeyDown(KeyCode.UpArrow)) { this.gameObject.transform.localScale = new Vector3(1, 1, 1); isjumpedin = false; rb.velocity = Vector2.up * jumpVelo; } else if (isjumpedinmv && Input.GetKeyDown(KeyCode.UpArrow)) { this.gameObject.transform.localScale = new Vector3(1, 1, 1); isjumpedinmv = false; rb.velocity = Vector2.up * jumpVelo; } //Coal throwing && decrement if (coalCount != 0 && Input.GetKeyDown(KeyCode.E)) { Debug.Log("Coal thrown"); coalSpawnPoint.GetComponent <CoalSpawner>().Spawn(); decrementCoal(1); } //Explosive ground code if (onExplosive()) { rb.velocity = Vector2.up * explVelo; } //Health Depletion if (currentHealth > 0) { currentHealth -= coef * Time.deltaTime; } healthBar.SetHealth(currentHealth); }