• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
3
Question by silverbackAlex · Jan 31, 2019 at 11:44 PM · animationconstraintsorder-of-execution

When do constraints, like ParentConstraint and AimConstraint, evaluate?

I frequently employ the LateUpdate method on MonoBehaviours to locate or modify animated Transforms, after their animations have been evaluated. This works with both Timeline and Mecanim state machines, and has any number of uses; such as temporarily pinning props to character's hands, or offsetting the rotation of a character's bones.

I have recently taken to using the AnimationModule's new Constraints, such as ParentConstraint and AimConstraint. They're fantastic, but I have just discovered that they do not evaluate in time for their output to be used in LateUpdate. If I query the position of a constrained Transform in LateUpdate, it appears to return its position from the previous frame, not unlike querying an animated Transform's position in Update.

The effect is fairly catastrophic, in that the position of any Transform, with a Constraint anywhere above it in the hierarchy, is more or less impossible to find. Even using WaitForEndOfFrame to retrieve the value inside a Coroutine seems to yield an incorrect result.

When do Constraints actually evaluate, and is there any way to get the current or final position of a Transform being driven by a constraint? Constraints have been such a delight to work with otherwise, I would hate to have to stop using them. Any help would be much appreciated.

As an example of why one might need to know the position of a constrained Transform; I have a Spline system where a number of Transforms can serve as the vertices of a Bezier Curve. The resulting Spline can then be sampled at intervals, and its samples can be used to position other GameObjects, or the vertices of a LineRenderer, or whatever. We use it for cables, hoses, ropes and wires. This system works marvelously with normal animations, but once constraints are involved - such as constraining the nozzle of a hose to a character's hand - there's no safe method in which to sample the Bezier Spline, and the resulting samples become a jittery mess.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
5
Best Answer

Answer by silverbackAlex · Feb 08, 2019 at 03:38 PM

For any future internet archaeologists who stumble across the same problem; I spoke to some people at Unity, and this appears to be a bug. Sampling the position of a constrained object in LateUpdate should yield the correct position, but there is some kind of problem with the execution order.

The devs are talking a look at it now, so likely it will be resolved in the near future. I'd welcome any alternative solutions in the meantime, but as the central mystery has been solved, I'll answer my original question:

At the time of this answer, there isn't currently a good way (or more accurately, a good time) to sample the position of a constrained object. As part of the AnimationModule, constraints are meant to be applied before LateUpdate, but some kind of bug is preventing that. The talented folks at Unity are currently investigating the problem.

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image AubreyH · May 01, 2019 at 06:12 PM 0
Share

Thank you very much. I am currently doing some I$$anonymous$$ using IAnimationJobs, and have a similar problem - the constraints don't see to react to the changes in transforms that are manipulated at all. If this is being fixed, I guess I just have to wait?

Did you find any way to force an extra update/evaluation of the constraint system manager?

avatar image silverbackAlex AubreyH · May 01, 2019 at 08:30 PM 1
Share

I'm told that update problem is fixed in "2019.2.0a11", so hopefully the change will be reflected in the "2019.2" release:

"Animation: Constraints are now evaluated before LateUpdate script (1123107)"

I didn't find a way to force an update, unfortunately. If you're not worried about making stable builds in the short term, you could try using the latest 2019.2 alpha, until the update.

Hope that helps!

avatar image ModLunar silverbackAlex · Jan 20, 2020 at 06:44 PM 0
Share

Thank you so much for the information, I am that future, grateful internet archaeologist haha! Hope your problems with this are all better now :)

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

260 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Can I make animations snap to a frame? 2 Answers

How to select an animation clip by index number? 7 Answers

Is that possible in unity? 1 Answer

How to play character animation after bone deparent? 2 Answers

How to force the editor to evaluate constraints? 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges