Advertisement
Guest User

Untitled

a guest
Feb 21st, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.50 KB | None | 0 0
  1. public virtual void Movement()
  2. {
  3. if (!isAttack)
  4. {
  5. if (Controls.GetAxis(Horizontal) != 0)
  6. {
  7. speed = Mathf.Clamp(speed + (speedrate * Time.deltaTime), 0, maxspeed);
  8. transform.rotation = Quaternion.AngleAxis(180 * (Controls.GetAxis(Horizontal) < 0).CompareTo(false), Vector3.up);
  9. facing = Controls.GetAxis(Horizontal);
  10. }
  11. else
  12. {
  13. speed = Mathf.Clamp(speed - (speedrate * Time.deltaTime), 0, maxspeed);
  14. }
  15. if (Controls.GetAxis(Horizontal) > 0)
  16. {
  17. isFacing = Mathf.Min(isFacing + (turnrate * Time.deltaTime), 1);
  18. }
  19. if (Controls.GetAxis(Horizontal) < 0)
  20. {
  21. isFacing = Mathf.Max(isFacing - (turnrate * Time.deltaTime), -1);
  22. }
  23. } else
  24. {
  25. speed = 0;
  26. }
  27. rb.velocity = new Vector3((speed * isFacing), rb.velocity.y);
  28. Jumping();
  29. }
  30.  
  31. public virtual void Jumping()
  32. {
  33. if (Controls.GetButtonDown(A) && isOnFloor && Controls.GetAxis(Vertical) >= 0 && (notPlaying("uu", "dd", "aa", "adb")))
  34. {
  35. if (lastmove == "")
  36. lastmove = anim.CurrentClip.name;
  37. isAttack = false;
  38. jump = maxjump;
  39. downstep = 0;
  40. upstep = 0;
  41. }
  42. if (!isAttack)
  43. {
  44. if (!isOnFloor && jump > jumprate*-1.5)
  45. {
  46. jump -= jumprate * Time.deltaTime;
  47. }
  48.  
  49. if ((Controls.GetButtonUp(A) && jump > 0) || (isOnFloor && jump < 0))
  50. {
  51. jump = 0;
  52. }
  53. } else
  54. {
  55. jump = 0;
  56. }
  57. rb.velocity = new Vector3(rb.velocity.x, jump);
  58.  
  59. }
  60.  
  61. public virtual void Animations()
  62. {
  63. if (!isAttack)
  64. {
  65. if (!isOnFloor)
  66. {
  67. if (jump > 0)
  68. {
  69. playThis("jump");
  70. }
  71. if (jump < 0)
  72. {
  73. playThis("fall");
  74. }
  75. }
  76. else
  77. {
  78. if (Controls.GetAxis(Horizontal) == 0)
  79. {
  80. playThis("idle");
  81. }
  82. else
  83. {
  84. playThis("run");
  85. }
  86. }
  87. }
  88.  
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement