Exemple #1
0
    public override void _Ready()
    {
        base._Ready();

        jumpGravity      = 2.0f * jumpHeight / Mathf.Pow(jumpDuration / 2.0f, 2);
        fallGravity      = 2.0f * jumpHeight / Mathf.Pow(fallDuration / 2.0f, 2);
        jumpSpeed        = -Mathf.Sqrt(2.0f * jumpGravity * jumpHeight);
        terminalVelocity = airborneTerminalVelocity;

        sprite          = GetNode("Sprite") as Sprite;
        animationPlayer = GetNode("AnimationPlayer") as AnimationPlayer;
        animationTree   = GetNode("AnimationTree") as AnimationTree;
        animationTree.SetActive(true);
        animationPlayback = animationTree.Get("parameters/playback") as AnimationNodeStateMachinePlayback;
        animationPlayback.Start("stand");

        hitbox = GetNode("Sprite/Hitbox") as Area2D;
        hitbox.Connect("area_entered", this, "_On_Hitbox_AreaEntered");
    }