How To Check If A Keyframe Fbx Animation Is Playing

Discussion in 'BBNodes' started by MFK2018, Apr 22, 2020.

  1. MFK2018

    MFK2018 Boxer

    Joined:
    Jan 19, 2018
    Messages:
    8
    Likes Received:
    3
    Hi there, I am pretty new to Javascript and thus posting this in need of some help, to code a custom script.

    I have a 3D FBX character animation playing, the two animation are kick & a sword slash by the character. the reason I want to have a 'check if animation function' implemented is because of button bashing and avoid making the combat look silly, with the character constantly repeating from the start of its frame.
    //------------------------------------ DETAILS -----------------------------------------
    What do I need to implement:
    A script between a [ UI button press ] & [ Key Frame Animation ]

    Script should check if an animation is playing. if it is currently playing.
    I ONLY want to play the animation If it is not already playing so already. so if a user bashes the kick button repeatedly, within the allotted animation duration time, only one animation is played. if that makes sense

    //----------------------- what I have tried:

    Code:
    var enabled = false;
    var animation;
    
    function init(){
        //animation = animation("Sword And Shield Slash")
        let attribute = this.attribute('Sword And Shield Slash');
        animation = new Animation(attribute, this);
    
    }
    
    function start(){
        if (!enabled) {
            return;
        }
     
        //CODE HERE TO CHECK
        if isAnimationPlaying(animation) { // ????
        } else {
            this.emitSignal('runAnimation', true);
        }
    
    }
    
    function update(dt){
     
    }
    
    function signal(name, value, sender){
        if (name == 'check' && value) {
            enabled = value;
        }
    }
    
    function requested(name, arg, sender){
        return this;
    }
    //-----------------------------------------

    Anyways could anyone help at all please? Or even point me at some material to further study. I have tried to follow the api guide on some points like isAnimationPlaying Screenshot 2020-04-22 at 19.17.59.png

    Thank you!
     

Share This Page