2016-04-15 12 views
-1

私はドキュメントをチェックしようとしましたが、私には正しいようですが、このプロジェクトをビルドしようとするとエラーが発生します。input.getaxis( "Vertical")のエラーを処理する方法がわかりませんか?

Input side = Input.GetAxis("Horizontal"); 
Input up = Input.GetAxis("Vertical"); 

Input.GetAxis戻りfloatいますが、Inputfloatないとも存在しませんたことを割り当てる:

using UnityEngine; 
using System.Collections; 

public class PlayerController : MonoBehaviour { 
    private Rigidbody rb; 

    void Start() { 
     rb = GetComponent<Rigidbody>(); 
    } 

    void FixedUpdate() { 
     Input side = Input.GetAxis("Horizontal"); 
     Input up = Input.GetAxis("Vertical"); 

     Vector3 movement = new Vector3 (side, 0.0f, up); 
     rb.AddForce (movement); 
    } 
} 
+1

エラーとは何ですか? –

答えて

0

あなたの過ちは、これら二つのライン上にあります。したがって、Input sideInput upfloat sidefloat upに置き換えてください。

public class PlayerController : MonoBehaviour { 

    // Use this for initialization 

    private Rigidbody rb; 

    void Start() 
    { 

     rb = GetComponent<Rigidbody>(); 

    } 

    // Update is called once per frame 



    void FixedUpdate() 
    { 

     float side = Input.GetAxis("Horizontal"); 
     float up = Input.GetAxis("Vertical"); 

     Vector3 movement = new Vector3(side, 0.0f, up); 

     rb.AddForce(movement); 


    } 
} 
関連する問題