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.
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:
Alternatively, you could try to use Signals instead, which will only trigger in playmode.
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)
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.
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.
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!
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.
Faux models or placeholders seem like a good idea.
I necro this post to share a solution I’ve came to for handling parenting into the timeline : a SetParentTrack.
The track itself reference the object you want to be parented, the track inspector let you define a default parent when there is no clip under the playhead (null = scene root), and each SetParent clip let you define the desired parent.
It’s my first Timeline customization so let me know if you think there is a better way to achieve this
Hi,
not sure if I am doing something wrong but unfortunately this offsets the child objects more and more from the original position everytime I scrub back and forth or rewind and play again several times in timeline. Is there a way to aviod that?
Cheers