Not physically ideal but good jump
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
public class GravityJump : MonoBehaviour { | |
public float fallMultiplier = 2.5f; | |
public float lowJumpMultiplier = 2f; | |
Rigidbody2D rb; | |
void Awake() { | |
rb = GetComponent<Rigidbody2D>(); | |
} | |
void Update() { | |
if (rb.velocity.y < 0) { | |
rb.velocity += Vector2.up * Physics2D.gravity.y * (fallMultiplier -1) * Time.deltaTime; | |
} else if (rb.velocity.y > 0 && !Input.GetButton("Jump")) { | |
rb.velocity += Vector2.up * Physics2D.gravity.y * (lowJumpMultiplier -1) * Time.deltaTime; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment