2016-12-30 13 views
0

私のキャラクターをanimationで歩いて、もう1人はanimationのままにしています。以下の図に示すようにControlesの変数animacaoが割り当てられていません

Animatorで、Iはアニメーション間の交換の制御を行うタイプfloatandarのパラメータを作成しました。


そして

enter image description here矢印に、以下の条件を割り当てる:

* andar> 0.1 = personagem。
* andar < 0.1 = personagemStop;

矢印の一つの例:

enter image description here


私のjavascriptのコード:

#pragma strict 

var speed : float; 
var personagem : GameObject; 
var animacao : Animator; 


function Start() { 
    speed = 2; 
} 


function Update() { 
    transform.position.x += Input.GetAxis("Horizontal") * speed * Time.deltaTime; 

    //THE ERROR OCCURS IN "andar"!!!!!_________________________________________ 
    animacao.SetFloat("andar",Mathf.Abs(Input.GetAxis("Horizontal"))); 
    //________________________________________________________________ 

    if(Input.GetAxis("Horizontal") < 0){ 
     personagem.gameObject.transform.eulerAngles = Vector2(0,180); 
    } 
    else if(Input.GetAxis("Horizontal") > 0){ 
     personagem.gameObject.transform.eulerAngles = Vector2(0,0); 
    } 
} 

多分それは、Unityバージョン

に関連したものになるかもしれません

私はこのチュートリアルに従っていました。
https://www.youtube.com/watch?v=PDuqGIB8j7E

マイUnityバージョン= 5.3.1f1
ユニティチュートリアルバージョン= 4.3.2f1


エラー:答えは簡単です

UnassignedReferenceException: The variable animacao of Controles has not been assigned. You probably need to assign the animacao variable of the Controles script in the inspector. UnityEngine.Animator.SetFloat (System.String name, Single value) Controles.Update() (at Assets/Assets/Scripts/Controles.js:17)

答えて

1

、あなたはドラッグする必要があり&アニメーターを保持するオブジェクトをスクリプトのanimacaoフィールドにドロップします.i nインスペクタ。それ以外の場合、スクリプトは使用するアニメーターを認識しません。

実際、ビデオには表示されていませんが、5:28頃に黒い画面で行われています。

+0

ありがとう、私は今夜テストし、あなたに警告します。 – CristianCotrena

関連する問題