Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Not physically ideal but good jump
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