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 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