Anim.setboolean condition

Hi, just wanna ask if we can return the anim.setboolean to false? after trigging it to “true” by button, thanks in advance

Hi @Genesis_Miranda,

Yes definitely, check this example on how it sets the boolean anim variable to true/false based on a key press:

1 Like

can we also make the condition to false, using timer for example?

Yes, that is possible. You create a timer and set the boolean to false

it doesn’t work on my end, the timer is 3 seconds to make the boolean condition false again, but the button wasn’t able to trigger the animation the 2nd time. here’s the project. PlayCanvas | HTML5 Game Engine

Looking at the graph, using triggers instead of booleans would be most likely be better as they can be set and then ‘reseted’ in the next frame:

Or you can just force the transition with layer.transition

I’m looking at your project and not entirely sure what you are trying to do.

Can you explain what you want to achieve and perhaps it be easier to give an example to work from?

I’m trying to make the button fire the animation again, multiple times, so every click will trigger the setboolean

In which case, use triggers or the transition function mentioned above.


Example script:

var BtnclickEAT = pc.createScript('btnclickEAT');

// initialize code called once per entity
BtnclickEAT.attributes.add('buttonEntity', { type: 'entity' });

// initialize code called once per entity
BtnclickEAT.prototype.initialize = function () {
    this.buttonEntity.button.on('click', function () {
        /** @type {pc.Entity} */
        var entity ="Anim_Pig_Idle");
        entity.anim.baseLayer.transition('eat', 0.1);
    }, this);
1 Like

wow, it works, thanks again for the help sir Yaustar