Search Unity

Blend animations or combine layers?

Discussion in 'Animation' started by DustyShinigami, Jun 24, 2019.

  1. DustyShinigami

    DustyShinigami

    Joined:
    Jan 5, 2018
    Posts:
    529
    I'm not sure what I should do with my animations. I have a walk and a shooting animation, but I want to be able to use both at the same time. With the shooting animation though, the projectile is a child object of the gun, and during the animation it activates and goes across the screen before deactivating. I may need to redo how I've done it at some stage so it's no longer a child of the gun.
    I did look into Blend Trees, but I don't think it's suitable in this case. If I try and blend walking and shooting together, the projectile appears from the gun before the character has raised it. What would be the best solution in this case? Is a Blend Tree the way to go and I just need to experiment with it more, or would combining layers work better...? I'm not clued up on how to use either method, so I'm not sure what or how I should approach it.
     
  2. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,570
    Layers are usually the best solution for this sort of thing. Play movement animations on the base layer and shooting on layer 1 with an AvatarMask that makes it only affect the upper body.
     
  3. DustyShinigami

    DustyShinigami

    Joined:
    Jan 5, 2018
    Posts:
    529
    See, this is what annoys me when people link to the documentation when I ask for help - they're still pretty vague and don't fully explain the procedure on how to set up and get things working. :-\ I've looked through the documentation and an official Unity video tutorial on how to set up multiple layers, but I still don't understand how I can get my animations working together. :( I mean, great, I've synced up my second layer, the weight is at 1, but big deal; both layers are running at the same time. I even tried applying an Avatar Mask, but it hasn't done much.
     
  4. DustyShinigami

    DustyShinigami

    Joined:
    Jan 5, 2018
    Posts:
    529
    Anyone? I've tried following this tutorial, but I still can't get it working properly.



    I even set up mask layers for both the base layer (legs) and the attacking layer (body/arm), but the character still floats when I fire and move. :(
     
  5. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,570
    See, this is what annoys me about people on the internet who ask for help - they're pretty vague about the problem they're having and often don't properly explain what they have tried, then they are ungrateful when you try to help and start complaining as if they were entitled to a fully detailed explanation about how to solve that exact problem which they didn't explain.

    Your only mention of layers was the statement "or would combining layers work better?" which led me to believe you hadn't actually tried using layers yet and were just looking for direction.

    What do you mean, you "tried applying an Avatar Mask, but it hasn't done much"? You tried to get it working but couldn't? You think you actually got it working but it's not doing what you want? You need to explain what it actually did and how that's different from what you wanted.

    Same for the tutorial. Are you saying you weren't able to follow the tutorial? Or you did and got a different result to them? Or you got the same result and it's still not what you want?

    The only thing I know about you is that your signature says you are a novice at scripting so instead of linking to the scripting oriented layers tutorial like I normally would, I just answered your question. "... would combining layers work better?" Yes.
     
    Davex6 likes this.
  6. DustyShinigami

    DustyShinigami

    Joined:
    Jan 5, 2018
    Posts:
    529
    Sorry. I’m a novice with most of Unity; I’m still learning everything. I get frustrated quickly if I don’t fully understand something. I’d say it’s linked to my Asperger’s. I can struggle at processing new info and get annoyed when I don’t get something or it doesn’t work. And then my frustration increases when I get little to no reply and feel directionless. And it’s also why being linked or checking the documentation feels underwhelming and vague.

    I do appreciate the reply and you trying to help though.

    Prior to my last post, everything I put was what I tried; I couldn’t think of anything more to add. And sorry for the confusion. Initially, yeah, I was just after some direction and I haven’t had any experience with Layers. I didn’t see the point in starting a whole new thread about it.

    With the Avatar Mask, I’ve tried selecting the parts I want affected and the ones I don’t, but nothing changes. For instance, the layer I want only the firing of the weapon to happen, I had the torso/arms selected, and the bottom half deselected. The character still floats along when firing. I’ve tried adding an Avatar Mask to both layers as well.

    I’ve been able to follow the tutorial in the sense that I understand it, but I’m not getting the same expected results; the same thing happens - the character floats when firing. :-/

    What I have tried doing though is messing with the Transform section instead of the Humanoid. I checked the parts I wanted effected for both layers. This does work and my character now walks whilst firing, however the projectile fires reeaaaallly slow and doesn’t finish it’s animation, therefore it doesn’t move across and come into contact with my enemy’s collider. Only thing I can think of now is looking up some other way of firing the projectile independently so it’s not a child object of the gun.
     
  7. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,570
    If the humanoid Avatar Mask is not working then you probably have your model using a Generic rig. That's the only reason I can think of for it to only work with Transforms.

    You should definitely not have the projectile as a child of the gun and usually not even part of the animation at all. I would probably use an Animation Event to determine when to fire, then just have a simple script spawn a bullet at the position and rotation of the gun barrel, then move it forward every update at whatever speed you want.
     
  8. DustyShinigami

    DustyShinigami

    Joined:
    Jan 5, 2018
    Posts:
    529
    A Generic rig...? What other types are there? How do you make different types? Haven't come across Animation Events either. o_O
     
  9. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,570