Skip to content

Instantly share code, notes, and snippets.

@daichi-takezawa
Last active April 29, 2021 19:19
Show Gist options
  • Save daichi-takezawa/ba5c251f2c79e618d314e946ac7ef77d to your computer and use it in GitHub Desktop.
Save daichi-takezawa/ba5c251f2c79e618d314e946ac7ef77d to your computer and use it in GitHub Desktop.
private bool jumpNow;
public float jumpPower; //調整必要 例850
private void OnCollisionEnter(Collision other) {
if (jumpNow == true) {
if (other.gameObject.CompareTag("Ground")) {
jumpNow = false;
}
}
}
void Jump() {
if (jumpNow == true) return;
if (Input.GetKeyDown(KeyCode.Space)) {
rb.AddForce(transform.up * jumpPower, ForceMode.Impulse);
jumpNow = true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment