So basically, is there a way to blend two animations?
I have a sword attack animation, and I have a walk animation. The sword attack animation works when idle, and then the walk obviously works while he’s walking.
But how can I combine it so the sword attack works while he’s walking too? Like so his upper body still attacks like the sword attack, but then his lower body (legs/hips) still work like the walk animation?
To achieve the result you want, you need to add a mixing transform. So basically, how this works is you define an armature in the characters body, and then every child of that armature will play one animation, while the rest play a different.
For Example:
using UnityEngine;
using System.Collections;
public class AnimationExample : MonoBehaviour {
public Transform upperBody; // This should be the bone from which all children will play attack animation
void Start() {
animation["SwordAttack"].AddMixingTransform(upperBody); // Adds a mixing transform using the bone transform defined above
}
void Update() {
animation.Play("RunAnimation");
animation.Play("SwordAttack");
}
}
To use this example, you would find the relevant armature in your character, then drag it onto the “upperBody” variable (or whatever).