Hi,
New to the forum, to Unity, and C#. Really, new to everything. I started my coding journey just about a year ago. So I ask your forgiveness if I am asking something simple or that has already been solved (although I have looked through all the posts and found nothing which prompted me to make an account!).
So, just some context for what my problem revolves around. I am creating a hero for a game where the rate of his attacks can be adjusted dynamically through items or "buffs". I am using TrackEntry to change the animation state on a track other than "0" in the update function or when another function is called:
var attackTrack = characterSkeleton.AnimationState.SetAnimation(1, Attack1, false);
attackTrack.EventThreshold = 1f;
attackTrack.AttachmentThreshold = 1f;
attackTrack.MixDuration = 0f;
var empty1 = characterSkeleton.state.AddEmptyAnimation(1, 3f, 0.1f);
empty1.EventThreshold = 1f;
empty1.AttachmentThreshold = 1f;
I have encountered two problems arising based off of my mechanic of "rate of attack":
1.If the rate of attack is fast enough, the animation is clipped, and restarts the attack animation
- The events which I have on the animations do not fire if the rate of attack is fast enough.
I have found if I change the Time Scale of the animations, I achieve what I want, the animation plays to completion AND the events fire.
The problem with that though is that the attack animations Rate of Attack changes dynamically and constantly and a constant time scale of 3 looks really wonky. Is there a way around this? Is there something im missing? Do I have to just suck it up and do SetAnimation(1, Attack1, false).Timescale = x; and do some crazy math that changes "x" based on an inverse relationship of Rate of Attack somehow?
My intended outcome is to have my animation of the attack play in full based on the rate of attack and raise the Event (Damage) that is on the animation. If the rate of attack is 1.5 seconds, then I want the animation to occur once every 1.5 seconds. Same goes if it is 0.5 seconds, I want the animation to occur once every 0.5 seconds.
I am sorry if this is a little confusing, I will clarify anything that I can or add anything that is needed. Please help! Anything is welcome!