0
こんにちは私はこのコードに問題があります。私はしばらくそれに取り組んできましたが、それを理解しているようには見えません。何が私が間違っているのでしょうか?(私は唯一のアニメーションビット上のトラブルを抱えている。)なぜこのユニティのアニメーション作品はありません
#pragma strict
public var clip : AnimationClip;
public var riffle : Sprite;
public var pistol : Sprite;
function Start() {
}
function Anima(){
GetComponent.<Animation>().Play(GetComponent.<Animation>().clip.name);
}
function Update() {
if(Input.GetKeyDown("a")){
print("A");
GetComponent(SpriteRenderer).sprite = riffle;
}
if(Input.GetKeyDown("d")){
print("D");
GetComponent(SpriteRenderer).sprite = pistol;
}
if(Input.GetKeyDown("w")){
Anima();
}
if(Input.GetKeyDown("s")){
Anima();
}
}
anima()関数の内部でNullReferenceExceptionが発生します。私はそれがどういう意味かはっきりしていません。 – mrboberson
クロスフェードを使用してください:https://docs.unity3d.com/ScriptReference/Animation.CrossFade.html –
あなたは確かに 'GetComponentですか?() 'が返品していますか? –
Serlite