The topic got closed for some reason. Just adding this here. Turns out I found a way to cleanly track the time into an anim notify state so I no longer need curves at all for what I was doing. You have to make the anim notify state a branch point inside an anim montage, which I need for what I’m doing anyway. Then override in C++ the anim notify branch point start and end.
From this you get the anim montage instance id, track number, and time window of the notify. This way I can track unique instances of a notify state. I also know exactly what time I’m in inside the anim notify state by getting the anim montage instance position. I find the the alpha of the notify state by getting the time range of the state, and the anim montage playback position. Knowing this alpha replaces the need for curves and I get clean notifies at starts and ends of states with a branch point, so there’s no more weirdness of not being at the exact curve keyframe.
I can also handle multiple montages blending in/out by tracking unique instances of notifies. I also know the weight of the montage instance so I can do some extra blending math with my results to get the correct values.
===== The rest is the old post =====
I noticed some unexpected behavior. I have these animation curves with “Constant” keys:
I expect that the value suddenly snaps from one value to the next on reaching the key.
However I noticed the curve value could be slightly interpolated. My code is reading the curve value as something close to 0 but not quite. It’s off by 2 decimal places so it’s not a small enough value to pass the equality check of a float being equal to zero. I also saw other times in my code where it was very close to 1, at values like .9987. I have a branch point at this spot as well, and call RefreshBoneTransforms. I expect the value to be either 0 or 1 exactly when sampling the curve, and there should be no in between. Could it be something to do with curve compression not working how I expect? Maybe the true value doesn’t reflect what you set in the editor and there’s no actual snap between keys?
Yeah I’m having to do that but it’s a bit hacky because there’s no information about whether the value is legitimately at the very edge or is ramping up at the smooth start in the beginning.
I guess it is also ambiguous whether the value is expected to be 0 or 1 at that exact keyframe. I have a notification state that goes along with this curve. I wish the value could be 1 at the end of the state but 0 at the beginning of the next state when their keyframes line up.
This would be easier if the engine let you track instances of anim notify states but there’s no info about that when they fire. Ideally I’d not use a curve at all and base the value off of the time within the notify state. The engine sends 0 as the current anim time when the notify fires which seems like a bug or oversight, so I can’t even resolve what time I’m at within the notify during the notify ticks. I saw the Motion Warping system does this a bit differently but it relies on tracking the current root motion animation, not some arbitrary animations playing on the mesh.
Anim notify is entierly async based (save for specific setups between transitions of state machines).
So there is no guarantee it will fire at all, let alone at the time you pick during an animation.
Really, we have no idea what you are attempting to do with this, but the way you are going about it needs to be better thought out.
If you know you need X values at X seconds of the animation playing, you can probably do exactly that.
Basing things off either a timeline, which is precises but has the same issue with only 1 keyframe per millisecond would already be more accurate.
Mostly because you have to remeber that an animation is never just that animation within the engine.
Its almost always interpolated/weighted onto something else. Be it an aim offset or a blendspace.
That potentially offsets the values of same named anim curves as well.
A dedicated timeline, or a dedicated curve asset, or just saying “at time x of animation y” would all be better solutions.
Also, given your curve screenshot above - more keys = better control.
The constant is not really a guarantee. 2 keyframes with different values in immidiate succession are.
I’ve been working on this project for a while and solved many edge cases and other issues so it’s pretty well thought out. I just recently added anim notify state branch points to make it even more robust.
I was hoping to get rid of curves alltogether and rely solely on Anim Notify States which is how the Motion warping system works.
It works for the Motion Warping because they don’t use the anim notify begin, end callbacks. They instead track the current root motion anim instance and the time in the animation. Then they figure out the alpha of the warping based on the position of the anim track within the notify state window.
That doesn’t work for me because my animations aren’t root motion. I actually tried to piggy back off the motion warping system and was hacking things so my transition animations would be root motion animations, but then there’s 0 root motion and my character couldn’t locomote around during an animation.
I’m doing a hybrid approach where I use both an anim curve and the notify state. I actually take advantage of the fact that the curve blends out as the animation interrupts and blends out. I trigger a foot lock event when the anim notify end state event is fired if the animation wasn’t interrupted, or when the curve is 0. This actually works well with the curve since without the explicit end branch point, the curve could go from 1 to 0.02 or something by next frame, and miss the point where it was exactly 0.