Movement via Animation Clip interacts badly with Set Parent

Slate Forums General Discussion Movement via Animation Clip interacts badly with Set Parent

This topic contains 4 replies, has 2 voices, and was last updated by  Gavalakis 6 days, 20 hours ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #2122

    dgoyette
    Participant

    I recently upgraded my project from Unity 2019.1 to Unity 2019.3, and in the process, upgraded to the latest version of Slate. So I don’t know if this is a regression in Slate, or due to a change in 2019.3.

    To keep it as simple as possible, it seems there are some bad interactions now between moving a parent via an Animation Clip while simultaneously using Set Parent to add a child to that object. Here’s a really simple example:

     

    SimpleCutscene

    I have an Animation clip, which simply rotates the object called “Rod”. In the track below that, I have an object using Set Parent to set it’s parent to “Rod”. If I play this in the Slate editor without pausing, it works as expected: The Rod rotates, and at some point, the “Arm Section” object parents to it, and also moves as you’d expect a child to move. However, at runtime (and if I scrub through the cutscene manually) the result is much different.

    The easiest way to reproduce this is to start dragging the red scrubber through the cutscene until after I’ve called set parent. At that point, the child object will be where you expect. But as soon as you let go of the mouse button, the child object will pop to some unexpected location.

    Note that if I rotate the “Rod” via a different kind of clip, a transform clip, this problem doesn’t occur. It’s only when the object rotates due to an animation clip.

    Now, in 2019.1, I found this was also the case, but only in the editor when scrubbing through. It worked fine in Play Mode. But now, in 2019.3, it’s broken in play mode as well.

    So, some questions:

    • Is it a known problem using SetParent to parent an object to another object that’s being moved via an Animation Clip?
    • Is there any way to work around this? The movement in the animation clip is very precise, and trying to accomplish that using Slate directly will be very difficult.

    Let me know if you need any more details on this.

    Attachments:
    You must be logged in to view attached files.
    #2124

    Gavalakis
    Keymaster

    Hello there,

    I can confirm that this is not working as expected, but please note that it’s not only when using Animation Clip, but also when translating the parent gameobject via say for example, a Translate To clip. The reason is quite technical, but the short version of this, is that when you let go of the mouse click (after scrubbing the timer), the cutscene is evaluated. What happens when re-evaluating is that the time moves back to zero and then back to the current (mouse click over) time.

    This of course happens behind the scenes in a single frame, but the problem with that instant re-evaluation is that certain clips (like Set Parent which may interact with other clips on separate Actor Groups like in your case example) will not re-evaluate correctly. When “playing” the cutscene normally however this behaviour should not happen (or does it in your case?).

    At this point, yes, I can confirm that this is unexpected behaviour and thus a bug that requires fixing. I may need to rethink the implementation of how re-evaluating the cutscene is done.

    Can you please confirm whether or not it works correctly when “playing” the cutscene normally however?

    Thank you!

    Join us on Discord: https://discord.gg/97q2Rjh

    #2125

    dgoyette
    Participant

    Under 2019.1, this was only an issue in the editor when scrubbing. I could “play” the cutscene in the editor without issue, and I could play the cutscene while in Play Mode without issue.

    Under 2019.3, however, the issue is now occurring while in Play Mode. I can “play” the cutscene in the Slate editor without issue, but while the cutscene is playing in Play Mode, it’s as though I scrubbed to one frame after the Set Parent call, released the mouse, and then continued to play. In other words, the object I’m calling SetParent on jumps to some weird location, and then continues to move with the parent. I still have an older version of Slate I was using in 2019.1 before I upgraded it with my move to 2019.3, so I’ll copy that into my project to help triangulate whether this is because of changes in Unity, or because of a change in Slate.

    #2126

    dgoyette
    Participant

    It looks like the change is in Slate, and not in Unity itself. I compared the current asset store versionĀ  (1.99) to what I’d been using before (1.91). Under 1.99, the parenting doesn’t work correctly. But under 1.91, it works correctly. That probably doesn’t help much to triangulate what changed. But I’ll most likely just stay on 1.91 for now. I’m not sure I’d be able to intuit why this behavior changed by diffing the two code bases. But in any case, it does seem like this is a post 1.91 regression, though I’m not sure whether you consider reparenting while another clip is translating the parent “supported behavior”.

    #2131

    Gavalakis
    Keymaster

    Hello again and thanks for the follow up and information. I will take a look at what could have possibly changed that affected this behaviour. Thank you!

    Join us on Discord: https://discord.gg/97q2Rjh

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.