Guest User

Untitled

a guest
Dec 18th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. using System.Collections;
  2. using UnityEngine;
  3.  
  4. public class BetterJump : MonoBehaviour {
  5.  
  6. public float FallMultiplier = 2.5f;
  7. public float lowJumpMultiplier = 2f;
  8.  
  9. RigidBody2D rb;
  10.  
  11. void Start() {
  12. rb = GetComponent<RigidBody2D>();
  13.  
  14. }
  15.  
  16. void Update() {
  17.  
  18. if (rb.velocity.y < 0) {
  19. rb.velocity += Vector2.up * Physics2D.gravity.y * (FallMultiplier - 1) * Time.deltaTime;
  20. } else if (rb.velocity.y > 0 && !Input.GetButton("Jump")) {
  21. rb.velocity += Vector2.up * Physics2D.gravity.y * (lowJumpMultiplier - 1) * Time.deltaTime;
  22. }
  23. }
  24.  
  25.  
  26. }
Add Comment
Please, Sign In to add comment