//Update protected override void ComputeVelocity() { Vector2 move = Vector2.zero; //is controller assigned? if (controllerNumber > 0) { move.x = Input.GetAxis(inputHorizontal); if (Input.GetAxis(inputVertical) >= 1) { Debug.Log("throw!"); if (ipReference) { ipReference.ThrowAway(); } else { Debug.LogError("Throw away failed for " + name + "! Missing Reference to ItemPickup component!"); } } else if (Input.GetButtonDown(inputAction)) { ipReference.item.action(ipReference.game); Debug.Log("action"); } else if (Input.GetAxis(inputVertical) <= -1) { Debug.Log("block"); } if (grounded && !isSliding && Input.GetButtonDown(inputSlide) && velocity.x != 0) { slide(); } else if (Input.GetButtonDown(inputJump) && grounded) { velocity.y = jumpTakeOffSpeed; //Debug.Log(inputJump); } else if (Input.GetButtonUp(inputJump)) { if (velocity.y > 0) { velocity.y = velocity.y * 0.5f; } } } else { Debug.LogWarning("Controller Number for " + name + " does not exist!"); } //get the current scale of the object Vector3 currentScale = transform.localScale; //flips the character acoording to the move input if (move.x == 0) { //Do not delete this condition, it is important! transform.localScale = currentScale; } else if (move.x > 0.01f && currentScale.x < 0) { currentScale.x *= -1; flipped *= -1; transform.localScale = currentScale; flippedRight = true; } else if (move.x < 0.01f && currentScale.x > 0) { currentScale.x *= -1; flipped *= -1; transform.localScale = currentScale; flippedRight = false; } animator.SetBool("grounded", grounded); animator.SetBool("isSliding", isSliding); animator.SetFloat("velocityX", Mathf.Abs(velocity.x) / maxSpeed); animator.SetFloat("velocityY", Mathf.Abs(velocity.y) / jumpTakeOffSpeed); targetVelocity = move * switched * maxSpeed; }