Skip to content

Instantly share code, notes, and snippets.

@masafykun
Created September 21, 2020 12:08
Show Gist options
  • Save masafykun/0e1006d0bbd121f8b7a999e1b657477b to your computer and use it in GitHub Desktop.
Save masafykun/0e1006d0bbd121f8b7a999e1b657477b to your computer and use it in GitHub Desktop.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class jump2dan : MonoBehaviour
{
int jumpCount = 0;
public Rigidbody rb;
void Update()
{
if (jumpCount < 2 && Input.GetKeyDown(KeyCode.Space))
{
rb.velocity = Vector3.zero;
rb.AddForce(0f,300f,0f);
jumpCount++;
}
}
private void OnCollisionEnter(Collision collision)
{
if (collision.gameObject.name == "groud")
{
jumpCount = 0;
}
}
}
//参考;https://stepism.sakura.ne.jp/unity/wiki/doku.php?id=wiki:unity:tips:069
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment