Advertisement
Guest User

movement

a guest
Sep 23rd, 2014
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. #pragma strict
  2.  
  3. var movement : float;
  4.  
  5. var jumpstrength : float;
  6. var jumpincrease : float;
  7. var jumpmax : float;
  8.  
  9. var jumpbool : boolean;
  10.  
  11. function Start () {
  12. jumpmax = 20;
  13. }
  14.  
  15. function Update () {
  16.  
  17. if (Input.GetButton ("Horizontal")){
  18. transform.position.x += movement;
  19. }
  20. if (Input.GetButton ("NegaHorizontal")){
  21. transform.position.x -= movement;
  22. }
  23. if (jumpbool == true){
  24. if (Input.GetButton ("Jump")){
  25. jumpstrength += jumpincrease;
  26. if (jumpstrength >= jumpmax){
  27. jumpstrength = jumpmax;
  28. }
  29. }
  30. if (Input.GetButtonUp ("Jump")){
  31. rigidbody.velocity.y += jumpstrength;
  32. jumpbool = false;
  33. jumpstrength = 6.5;
  34.  
  35. }
  36. }
  37. }
  38.  
  39. function OnCollisionEnter () {
  40.  
  41. jumpbool = true;
  42.  
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement