How to add logic when transitioning between states of an anim component? I am interested in the transition between states, not the events on the animations themselves, since I will change them in the process.
In fact, when I call the transition myself from script - I put a random animation from the set of animations for specific state, the same thing I want to do for automatic transitions, like ‘falling’ playing after ‘jump’ (or create it from script but for state, not every animTrack).
Is there a clean solution or will I have to constantly add events to the animations that I randomize?
Player.prototype.animTransition = function(state, time = 0, offset = null){
this.skinEntity.anim.baseLayer.assignAnimation(state, getRandomElement(SOME_RANDOM_ANIMS).resource)
this.skinEntity.anim.baseLayer.transition(state, time, offset);
};
Note that to prevent eternal recursion in case your states are closed by transitions in a loop, checkStateRandomAnim method should be reworked. Example below.