Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float moveInput = Input.GetAxis("Horizontal");
- if (moveInput != 0)
- {
- anim.SetBool("IsRunning", true);
- if (currentSpeed < MaxSpeed)
- Mathf.SmoothDamp(currentSpeed, MaxSpeed, ref currentSpeed, Axceleration ,MaxSpeed , Time.deltaTime);
- Vector2 moveVector = new Vector2(currentSpeed,0);
- if(moveInput < 0)
- {
- transform.Translate(-moveVector * Time.deltaTime);
- }else if (moveInput > 0)
- {
- transform.Translate(moveVector * Time.deltaTime);
- }
- }
- else
- {
- if (currentSpeed >= 0 && IsGrounded)
- {
- currentSpeed -= DeAxceleration;
- // this only needs to be called if the player is on the ground but IsGrounded doesnt work
- }
- anim.SetBool("IsRunning", false);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement