Skip to content

Instantly share code, notes, and snippets.

@masafykun
Created September 21, 2020 12:08
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
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