为什么在他跳跃期间不会胜过有生命的动画?

时间:2016-04-09 04:29:46

标签: javascript unity3d unityscript

我想让特朗普在跳跃时输入他的跳跃动画。我该如何工作?我一直都有错误。

var jump = false;
var speed = 3.0;
var object;
var trump;
var jumpAnim : AnimationClip;
function Start()
{
trump = GetComponent(Rigidbody2D);
GetComponent.<Animation>().AddClip(jumpAnim, "jumpAnim");
var object = GetComponent(Rigidbody2D);
}

function OnCollisionEnter2D(collision: Collision2D) {
    jump = false;
    trump.velocity.y = 0;
}


function FixedUpdate() {
    if (Input.GetKey(KeyCode.LeftArrow))
    {
        trump.AddForce(Vector2(-4,0), ForceMode2D.Impulse);
    }
    if (Input.GetKey(KeyCode.RightArrow))
    {
        trump.AddForce(Vector2(1,0), ForceMode2D.Impulse);
    }
    if (Input.GetKey(KeyCode.UpArrow)) {
        if (jump == false) {
            Animation.Play("jumpAnim");
            trump.AddForce(Vector2(0, 10), ForceMode2D.Impulse);
            jump = true;
        }
    }
    if (Input.GetKey(KeyCode.DownArrow)) {
        trump.AddForce(Vector2(0, -0.5), ForceMode2D.Impulse);
    }
    if (trump.position.y <= -5)
    {
        Application.LoadLevel(0);
    }

它不会让他变得有生气。我也不知道如何恢复旧动画。游戏一直告诉我他没有动画,但他们都在那里,所以发生了什么?我该如何解决?

enter image description here enter image description here

0 个答案:

没有答案