Unityちゃんを前進させたいのですが、うまくいきません。RigidBodyのコンポーネントの問題なのでしょうか?
こちらがキャラクターを前進させるスクリプトです。
using System.Collections; using System.Collections.Generic; using UnityEngine; public class UnityChanControl : MonoBehaviour { private Animator myAnimator; private Rigidbody myRigidbody; private float forwardForce = 800.0f; // Use this for initialization void Start () { //Animatorコンポーネントの取得 this.myAnimator = GetComponent<Animator>(); this.myAnimator.SetFloat("Speed", 1.0f); this.myRigidbody = GetComponent<Rigidbody>(); } // Update is called once per frame void Update () { //AddForce関数は、RigidBodyクラス、 //transform.forwardで前方への力の方向を示す this.myRigidbody.AddForce(this.transform.forward * this.forwardForce); Debug.Log("a"); } }
必要な情報があれば、返事しますので、どなたかアドバイスよろしくお願いいたします。
回答1件
あなたの回答
tips
プレビュー