Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.

    Read our full announcement for more information and let us know if you have any questions.

Question Timeline animations and positioning game objects relative to other objects

Discussion in 'Timeline' started by Mufelo, Jan 4, 2021.

  1. Mufelo


    Feb 17, 2020
    This is probably a common enough use case, but I am new to Timeline so here goes (I'll happily accept links to existing solutions / examples - I couldn't find a concrete enough example for my tiny brain):

    I am implementing a cutscene that is to take place where the action ends. In practice, I want some characters to walk in and grab another character by the hand and walk them out.

    Now the problem, obviously, is that the "other character's" initial location depends on the scene and can even vary within a scene (depending on where the character happens to be). How do I position the game objects so that they start from the same offsets relative to the character being dragged out? Now assume that the character doing the "dragging" will also be a Game Object from the scene although I guess a way around that would be to hide the original and clone it to the correct spot and then animate weight variable in the IK Rig to do the arm grabbing.

    Any idea how to do it? I know I could do this via code and manually just doing the movements, setting animations and so forth, but this seems awfully inconvenient and rigid way to go about. Any help would be greatly appreciated.
  2. DavidGeoffroy


    Unity Technologies

    Sep 9, 2014
    Copied from my answer on Unity Answers:

    You pretty much have the right idea.

    Either you clone and hide, or you disable inconvenient scripts and use the existing instances. In either case, it's up to you to figure out what works with your game logic.

    You need to animate the "dragger" object with a given rig, and bind the instance you want to use at Runtime through the PlayableDirector.

    As for getting it in the right position:

    • A lot of developers people cheat by using camera cuts

    • You can use pathfinding and a blend in to get them close enough
    But there's no out of the box, one step way of doing this, since what needs to happen depends heavily on how your game logic is setup.
  3. canis


    Oct 25, 2013
    Hi Mufelo,

    I just did the similar thing in my project, may not the best solution, hope it can give you an idea.
    my solution are calculate the relative position & rotation manually,
    in my case, find the relative position by using Matrix4x4's multiplication, I mean world to local space, and back to world space that math stuff. blah blah.

    the different between your and I, you dealing with NPC but for me it's obstacle on the road.
    you shouldable to do the same thing on your NPC.
    In video 0:30 are the Gizmos debug for the relative position prediction for my jump animation
    prediction, angle, out range detection....etc
    and after 0:46 I put the yellow box in my timeline to identify the pivot point of the timeline.
    as you can see I'm using the script to correct the timeline position based on my character action,
    so the timeline will start playing based on that coordinate.

    PS: if you don't wanted to calculate matrix, you may do it though gameobject hierarchy.
    like setup the start interaction coordinate (a marker for player) under your NPC's hierarchy.
    and try to matching that coordinate by your own method (e.g. target matching, navmeshagent, it's up to you.)
    Last edited: Jan 5, 2021