Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Timeline: Parenting and Unparenting

Discussion in 'Timeline' started by Mario167100, May 29, 2020.

  1. Mario167100

    Mario167100

    Joined:
    Jul 25, 2016
    Posts:
    49
    Hey y'all.
    Right now, I'm using Unity as an animation station as opposed to a game engine. Currently, i'm working on an animated scene that has a character pick up a gun and put it back down again. My question is, how exactly do I parent and unparent a gameobject to another gameobject within timeline.
     
  2. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    It isn't possible out of the box with timeline, but it is something you can write your custom track/clip to do. One of the major roadblock to re-parenting in timeline is previewing - reparenting in the editor will cause changes to the scene. Timeline 'previews' any properties it changes.

    More about timeline scripting:
    https://blogs.unity3d.com/2018/09/05/extending-timeline-a-practical-guide/

    Alternatively, you could try to use Signals instead, which will only trigger in playmode.
     
  3. Mario167100

    Mario167100

    Joined:
    Jul 25, 2016
    Posts:
    49
    If it's possible, can you explain how I would accomplish this using timeline signals?
    (Also, I hope that they allow easy parenting in future builds. I do know of a asset package called UMotion that can possibly help with this, but I just paid off some some stuff and I'm going to have to wait for my next paycheck)
     
  4. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    Here's a sample of how to do it.

    The pieces used are a
    * signal asset to act as the signal identifier
    * signal emitters on the track to tell the object to re-parent
    * signal receiver on the Cube to call a custom script that cycles through a list of parents, re-parenting to the next one in the list.
     

    Attached Files:

  5. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,331
    Here's another idea: instead of parenting/unparenting, could you just have 2 guns? One parented to the hand and the other not. Then activate/deactivate them from timeline.
     
    hbguler and wm-VR like this.
  6. Mario167100

    Mario167100

    Joined:
    Jul 25, 2016
    Posts:
    49
    I haven't tried the signal package seant_unity sent, but that idea reminds me of stuff I used to do in other animation programs aswell as game prototypes i've built in the past. Thanks!
     
  7. Mario167100

    Mario167100

    Joined:
    Jul 25, 2016
    Posts:
    49
    I tried your package and it worked. I'm gonna have to find a way to figure out how to exactly track the gun that is being parented within the editor. One idea I had was making a duplicate, faux object that would be used as a model for what actually goes on in game. If you got any suggestions, that would be good.
     
  8. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    Faux models or placeholders seem like a good idea.