-5
我在做滾球教程,我的球沒有移動。我檢查了輸入設置。我甚至設定速度值,甚至添加Time.deltaTime但身體不動如何在unity3D中移動玩家?
using UnityEngine;
using System.Collections;
public class PlayerController : MonoBehaviour
{
public float speed;
private Rigidbody rb;
void Start()
{
rb = GetComponent<Rigidbody>();
}
void FixedUpdate()
{
float moveHorizontal = Input.GetAxis("Horizontal");
float moveVertical = Input.GetAxis("Vertical");
Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
rb.AddForce (movement * speed);
}
}
使用UnityEngine;使用System.Collections;公共類PlayerController:MonoBehaviour {公共浮動速度;私人Rigidbody rb; void Start(){rb = GetComponent (); } void FixedUpdate(){float moveHorizontal = Input.GetAxis(「Horizontal」); float moveVertical = Input.GetAxis(「Vertical」); Vector3運動=新Vector3(moveHorizontal,0.0f,moveVertical); rb.AddForce(運動*速度); }} – user38126
請**編輯**你的問題追加代碼。 – zwcloud
您是否將此腳本附加到遊戲對象,並且它是否還有一個隆起的身體? –