Search Unity

Combining animation clips

Discussion in 'Animation' started by arumiat, Jul 20, 2014.

  1. arumiat

    arumiat

    Joined:
    Apr 26, 2014
    Posts:
    321
    Right, so I'm trying to recreate something similar to
    this animation from Blender, it's a nerve impulse (in theory!) travelling up and then back down a nerve..

    Instead of using just the 2 spheres like in Blender I've used 4 in Unity as I thought this would give me more control, - 1 to go up to the point where the nerve splits, 2 separate spheres to travel along each branch and return to where they started, and a 4th to travel back down the nerve. I've manually keyframed an animation clip for each of these 4 spheres.

    I'd now like to combine this separate clips together so that sphere 1 reaches the fork and becomes invisible, and then sphere 2 and 3 become visible and start along their paths, return to where they started (become invisible) and sphere 4 sets off.

    I'd like the whole thing to play on loop.

    I've tried offsetting times that each individual sphere starts in the animation window but no matter what I do all of the clips start at the same time when I hit play. Addtionally toggling the mesh renderer on and off in the animation clip isn't producing the desired result in terms of making the spheres appear and disappear.

    Is the optimal way to combine them now via the animator and mecanim or via scripting?

    Appreciate your guidance,
    A
     
  2. numberkruncher

    numberkruncher

    Joined:
    Feb 18, 2012
    Posts:
    953
    It might be worth using Bezier curves as 'tracks' for your moving points. You could create one curve for each path.

    There are several assets available which can help with this type of thing; for instance, here is one which looks good (although I haven't used it):

    https://www.assetstore.unity3d.com/en/#!/content/11278

    I hope that this helps :)
     
  3. TMPxyz

    TMPxyz

    Joined:
    Jul 20, 2012
    Posts:
    766
    IMO, you just need to make ONE clip, including 3 spheres, (A,B,C)
    when A hits endpoint, the BC will become visible and set off to A's startpoint. over.

    make this clip loop and it should be done.
     
  4. arumiat

    arumiat

    Joined:
    Apr 26, 2014
    Posts:
    321
    Thanks both

    This is a pure GUI method TMPxyz? The reason I created separate scripts was that I can't see how you can have different gameojects in a single animation clip? I can see that you can attach different .anims to different objects to give them the same behaviour but not using one clip to control multiple objects?
     
  5. TMPxyz

    TMPxyz

    Joined:
    Jul 20, 2012
    Posts:
    766
    You could create an empty gameobject X, and three spheres A/B/C,
    attach A~C as child objects of X;
    then make animation clip on X, the clip will has access to A/B/C.

    20.jpg
     
  6. arumiat

    arumiat

    Joined:
    Apr 26, 2014
    Posts:
    321
    Nice! I'll give this a go, cheers man
     
  7. arumiat

    arumiat

    Joined:
    Apr 26, 2014
    Posts:
    321
    So I've got my 3 impulse objects childed to an empty parent game object. I opened up the transform position and rotation curves in an animation clip and tried to animate only 1 object, but it's taking the median point of the 3 game objects and although not keyframing the other 2, it is still moving them around as well frustratingly as I move just the first object I'm trying to animate. Do I need to be setting pivot points or origins or something for each of them individually to allow me to animate them individually whilst they are all a child of the same object?
     
  8. TMPxyz

    TMPxyz

    Joined:
    Jul 20, 2012
    Posts:
    766
    You could make curves for individual children objects.
    See the pic I posted, I make position curves for obj A and B to move to different directions.
    It has nothing to do with pivot or median point.

    if the three objects are siblings, then moving one of them should not affect the other two.
    Are you sure that you're not moving the parent?
     
  9. arumiat

    arumiat

    Joined:
    Apr 26, 2014
    Posts:
    321
    Did you alter the child objects position through the scene view? I need to keyframe through the scene view though, which involves having the object in question selected. As soon as I click the object i question it wants me to place an animation clip on that object, rather than the parent, even if I've exposed the properties I need in the animation clip on the parent...

    If I keyframe the object separately first and then child it, the animation clip remains with the child, and not the parent. I;ve tried copying and pasting the keyframes onto the child object within the parents animation clip but this doesnt work either..
     
  10. TMPxyz

    TMPxyz

    Joined:
    Jul 20, 2012
    Posts:
    766
  11. arumiat

    arumiat

    Joined:
    Apr 26, 2014
    Posts:
    321
    So I dont get why it's not working for me. I follow exactly as you do. Somehow your sphere autohighlights after you've created the animation clip. My empty gameobject is what is highlighted, not one of the children. As soon as I try and click those I lose access to the parent animation clip. How did you make that screencast I can demonstrate..
     
  12. TMPxyz

    TMPxyz

    Joined:
    Jul 20, 2012
    Posts:
    766
    You need Make sure the child objects don't have animation/animator component
     
  13. arumiat

    arumiat

    Joined:
    Apr 26, 2014
    Posts:
    321
    BOOM! Thank you so much TMPxyz :)

    How did you record your screencast and embed it like that?
     
  14. TMPxyz

    TMPxyz

    Joined:
    Jul 20, 2012
    Posts:
    766
    Glad can help.

    Google "Record gif", you could get a bunch