0
\$\begingroup\$

I have a hero that can aim his gun.

When the user aims down, I play the animation "gun_aim_lo". When the user aims up, I play the animation "gun_aim_hi".

I do this via a BlendTree.

enter image description here

The "BlendVal" is set by the current mouse position.

float f = Input.mousePosition.y / Screen.height;
_animator.SetFloat("BlendVal", f);

This works fine.

When the user then presses the fire button, the hero shoots his gun.

I play the gun_shoot animation using a Triggger like that:

_animator.SetTrigger("PistolShootTrigger");

enter image description here

However, I have now noticed that I need different gun_shoot animations, just like for the aiming: I need a gun_shoot_hi and a gun_shoot_lo animation according to the aiming position, else it would look strange if the user for example aims low and then the shoot-straight-animation is being played.

I would need to be able to blend between them according to where the user aims when he shoots.

Can I combine a BlendTree with a trigger?

I think I can only trigger single animations, and not a blend tree.

Can somebody tell me how my idea could be achieved?

\$\endgroup\$
4
  • \$\begingroup\$ I've not got time for a full answer but I'm pretty sure you can achieve what you want using animation rigging, I believe the Unity tutorial video for Animation Rigging covers exactly what you're trying to do, except they do it with a bow, I will provide the link shortly when I find the exact one I was talking about, there are a few! \$\endgroup\$ Commented May 15, 2021 at 12:41
  • \$\begingroup\$ This is a problem which might also be solvable with IK targets. Instead of having different aim points, you just set up an IK point in your character rig which allows the character to aim at any arbitrary height. \$\endgroup\$
    – Philipp
    Commented May 15, 2021 at 12:45
  • \$\begingroup\$ The Animation Rigging package, allows you to create procedural animations on top of your "pre-baked" animations by manipulating/constraining bones, I cannot find the exact video I was referencing (really annoying) but Unity does provide a way to do this via the Animation Rigging Package, there are a lot of unofficial tutorials too, apologies for not being able to provide much more help or information, it's just something I've done before so I can say it does work, but I do not know the content well enough to explain it to another. Searching "Animation Rigging Unity" is a good place to start! \$\endgroup\$ Commented May 15, 2021 at 13:05
  • \$\begingroup\$ Thank you, you two. I'm trying to perfectly rebuild RE4, and I know that they use high / mid and low poses and blend between them, also for gun shooting, so I would like to stay with my blend tree approach. \$\endgroup\$
    – tmighty
    Commented May 15, 2021 at 14:04

1 Answer 1

1
\$\begingroup\$

I should not have been so anxious.

I just replace the Pistol Shoot Animation with a Pistol Shoot BlendTree. The Pistol Shoot BlendTree uses "BlendVal" as well, so I don't have to change anything.

It works great.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .