Search Unity

  1. Unity 2020.1 has been released.
    Dismiss Notice
  2. We are looking for feedback on the experimental Unity Safe Mode which is aiming to help you resolve compilation errors faster during project startup.
    Dismiss Notice
  3. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Core.EvaluateClip returns interpolated values near keyframes even with Both Tangets set to Constant

Discussion in 'Animation Previews' started by threedots1, Jul 22, 2020.

  1. threedots1

    threedots1

    Joined:
    Oct 9, 2014
    Posts:
    71
    I'm setting hash values in float curves for sprite swapping, and the curve values are set to constant.

    Works perfectly fine except for right on keyframes. The sprite swaps correctly, however just before the swap the returned hash value is neither the previous sprites hashcode nor the new sprites hashcode, so it breaks.

    I think it's a bug in evaluate clip, as I understand that's where the interpolation happens, but I need to investigate further. Am I missing something here?
     
  2. threedots1

    threedots1

    Joined:
    Oct 9, 2014
    Posts:
    71
    Having looked through the code some more, it seems that I'll just have read the nearest frame manually to ensure this doesn't happen. EvaluateClip will always interpolate, so even though the curve is set to constant, that only applies to the frames themself. Interframe values will be interpolated!

    EDIT:

    More looking into the code. It's turning out to be quite frustrating trying to figure out where in the Samples blobarray I need to go to find the value I need, as there is currently no simple helper function to retrieve a single key value. It doesn't help that trying to debug values out of it often crashes Unity.

    Might I ask why the Spriteswap hashes are stored in the float channel rather than the int channel? As the code currently stands the int channels always return the leftKey frame value with no interpolation, whereas the float channels interpolate between the leftKey and rightKey.

    Surely it makes more sense to store it in the int channel and do no interpolation on any ints?
     
    Last edited: Jul 22, 2020
unityunity