void UpdateMoveAndAnim() { if (playerTriggerController.collisions.caixaDagua) { velocity.y = maxJumpHeight * 1.8f; } targetVelocityX = joyInput.x * speed; velocity.x = Mathf.SmoothDamp(velocity.x, targetVelocityX, ref velocityXSmoothing, (dogController.collisions.below) ? accelerationTimeGrounded : accelerationTimeAirborne); dogController.Move(velocity * Time.deltaTime, input); dogAnim.ChangeDogAnim(velocity, joyInput); }
// Update method called once per frame private void Update() { // If the player stands on something the velocity is not accumulated if (_controller.collisions.above || _controller.collisions.bellow) { velocity.y = 0; } velocity.x = 0; velocity.y += 10 * gravity * Time.deltaTime; // Update the state machine stateMachine.Update(); // Move the AI with the newly calculated vector velocity _controller.Move(velocity * Time.deltaTime); }
public void SetMovement(float _inputX) { input.x = _inputX; if (stun == false) { targetVelocityX = input.x * speed; } velocity.x = Mathf.SmoothDamp(velocity.x, targetVelocityX, ref velocityXSmoothing, (aiController2D.collisions.below) ? 0.1f : 0.2f); velocity.y += gravity * Time.deltaTime; if ((aiController2D.collisions.below || aiController2D.collisions.climbingSlope || aiController2D.collisions.descendingSlope) && !isJumping) { velocity.y = 0; } /*if (triggerController.triggerCollision.caixaDagua) * { * velocity.y = maxJumpHeight * 1.8f; * }*/ aiController2D.Move(velocity * Time.deltaTime, input); }