Advertisement
Guest User

Untitled

a guest
Feb 16th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1.  
  2. float moveInput = Input.GetAxis("Horizontal");
  3.  
  4. if (moveInput != 0)
  5. {
  6. anim.SetBool("IsRunning", true);
  7.  
  8. if (currentSpeed < MaxSpeed)
  9. Mathf.SmoothDamp(currentSpeed, MaxSpeed, ref currentSpeed, Axceleration ,MaxSpeed , Time.deltaTime);
  10.  
  11. Vector2 moveVector = new Vector2(currentSpeed,0);
  12.  
  13. if(moveInput < 0)
  14. {
  15. transform.Translate(-moveVector * Time.deltaTime);
  16. }else if (moveInput > 0)
  17. {
  18. transform.Translate(moveVector * Time.deltaTime);
  19. }
  20. }
  21. else
  22. {
  23. if (currentSpeed >= 0 && IsGrounded)
  24. {
  25. currentSpeed -= DeAxceleration;
  26. // this only needs to be called if the player is on the ground but IsGrounded doesnt work
  27. }
  28.  
  29. anim.SetBool("IsRunning", false);
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement