3dのキャラクターの移動方法なのですがRigidbody.velocityを使っているのですがAddFroce()を使うと動作しません
この原因を教えてくれますでしょうか? ※ジャンプキー入力部
C#
1public class PlayerController : MonoBehaviour { 2 3 private Rigidbody rb; 4 //public CharacterController cc; 5 private GameObject player; 6 public float jumpForce; 7 public float gForce; 8 private Vector3 v; 9 private bool isground = true;//地面の場合はtrue 10 private Vector3 jumpv; 11 12 // Use this for initialization 13 void Start () { 14 rb = GetComponent<Rigidbody>(); 15 v = new Vector3(); 16 jumpv = new Vector3(0,jumpForce,0); 17 } 18 19 void FixedUpdate() 20 { 21 22 } 23 24 // Update is called once per frame 25 void Update () { 26 int key = 0; 27 28 //スペースキー ジャンプ 29 if(Input.GetKey(KeyCode.Space)) 30 { 31 // Debug.Log("ジャンプ"); 32 if(isground == true) 33 { 34 //rb.AddForce( jumpv * Time.deltaTime); 35 rb.velocity = jumpv; 36 isground = false; 37 } 38 } 39 } 40 41 private void OnCollisionEnter(Collision other) 42 { 43 string name = other.gameObject.tag; 44 if ("isground" == name) 45 { 46 isground = true; 47 Debug.Log("地面に着地"); 48 } 49 } 50}
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。