1秒経ったらジャンプ、また1秒経ったらジャンプ・・・というコードを書いたのですが、ジャンプしてくれません。
ご教授願います。
c#
1using System.Collections; 2using System.Collections.Generic; 3using UnityEngine; 4 5public class JumpController : MonoBehaviour { 6 private Rigidbody2D rb2D; 7 private float jumpForce = 10.0f; 8 9 void Start () { 10 rb2D = GetComponent<Rigidbody2D>(); 11 } 12 13 void Update () { 14 Jump (); 15 } 16 17 IEnumerator Jump(){ 18 while (true) { 19 rb2D.velocity = new Vector2 (rb2D.velocity.x, jumpForce); 20 yield return new WaitForSeconds (1.0f); 21 } 22 } 23} 24
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2018/07/18 09:56 編集
2018/07/18 10:13
退会済みユーザー
2018/07/18 10:17