Advertisement
Guest User

Untitled

a guest
Sep 18th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class Player : MonoBehaviour
  6. {
  7. Rigidbody rb;
  8. public float s = 10f;
  9. public float score;
  10. public float rs = 10f;
  11. Vector3 v, r;
  12. public float j = 0f;
  13. // Start is called before the first frame update
  14. void Start()
  15. {
  16. rb = GetComponent<Rigidbody>();
  17. }
  18.  
  19. // Update is called once per frame
  20. void Update()
  21. {
  22. float x = 0, y = 0, z = 0;
  23. float j = 0;
  24. if (Input.GetKey(KeyCode.W))
  25. {
  26. z = 1;
  27. }
  28. if (Input.GetKey(KeyCode.S))
  29. {
  30. z = -1;
  31. }
  32. if (Input.GetKey(KeyCode.D))
  33. {
  34. y = 1;
  35. }
  36. if (Input.GetKey(KeyCode.A))
  37. {
  38. y = -1;
  39. }
  40. if (Input.GetKey(KeyCode.Space))
  41. {
  42. if (transform.position.y <= 0.55)
  43. {
  44. j = 20;
  45. z += 1;
  46.  
  47. }
  48. }
  49.  
  50. v = new Vector3(x, j, z) * Time.deltaTime * s;
  51. r = new Vector3(0, y, 0) * rs;
  52.  
  53.  
  54.  
  55. }
  56. private void FixedUpdate()
  57. {
  58. rb.AddTorque(r);
  59. rb.AddRelativeForce(v);
  60.  
  61. }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement