Keldryn said: I would probably set it as a float object variable on each Combatant, and then write up a simple component that gets that float variable value and sets the Femininity parameter on the animator.
You could do it through the Event system, but (in my opinion) it would be more straightforward to just use a component for something like this:
using ORKFramework; using UnityEngine;
namespace MyGame.Animation { [RequireComponent(typeof(Animator))] public class CombatantFloatParameter : MonoBehaviour { [Tooltip("The name of the ORK Combatant variable.")] public string VariableKey;
[Tooltip("The name of the float parameter on the Animator Controller.")] public string ParameterName;
[Tooltip("Indicates that the variable is a normalized float value within the range 0.0 to 1.0 (inclusive)")] public bool IsNormalizedValue = true;
[Tooltip("If the value of the Combatant variable will not change after initialization, then we only need to get it once.")] public bool GetOnce = true;
/// <summary> /// Attempt to get a reference to the ORK Combatant. /// </summary> private void GetCombatant() { _Combatant = ComponentHelper.GetCombatant(this.gameObject); _IsInitialized = _Combatant != null; }
private void Update() { // Ensure that the Combatant reference exists. if (!_IsInitialized) { GetCombatant(); return; }
// Get and store the value of the float parameter. if (_RefreshValue) { _BlendValue = GetValue(); // We're getting the variable value in the Update() loop, so if we only need // to get the initial value, we can save ourselves a call to the ORK API and just // use the stored value if (GetOnce) { _RefreshValue = false; } }
/// <summary> /// Get the value of the ORK Combatant float variable /// </summary> /// <returns></returns> private float GetValue() { float blendValue = _Combatant.Variables.GetFloat(VariableKey);
// If the variable represents a normalized value, ensure it is within the valid range return IsNormalizedValue ? Mathf.Clamp01(blendValue) : blendValue; } } }
Set up the object variable on the Combatant like this:
I was just going to whip up a quick script to set that parameter on Start(), but it was marginally more work to make it usable for any float variable that you might want to convert to an Animator parameter.
Just come to say thank you for your tutorial. It give me a lot of ideas about animation set up in unity.
For example that you can combine 2 animations with avatar mask. I use this technique for drinking potion. I make another layer with left hand avatar mask for use drinking animation that animate only my character left hand and it work perfectly.
Now, I can make a lot of animation by using avatar mask technique.
@pawnee You could probably do that in an Equip Game Event on your weapon, using a Mecanim Animation node to change the parameter.
Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found. If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
@pawnee - The MoveSetID is set when you play the animation:
This is from Part 2: Battle Mode Animations (Basic) - Sword (and Shield) Animations.
You specify the set of battle animations to use for a weapon in that weapon's properties (this is also covered in the tutorial). It's a very long tutorial, so it's easy to miss something. :-)
I have a question. How would you go about creating death animations if you want characters to have for example their heads be cut off the body with geysers od blood?
I was thinking about removing the original prefab and swapping it for 3 prefabs (one for body other for head and a prefab for geyser of blood). However this approach requires having additional models and I expect it to cause some problems with clothes.
Is there some other, more efficient approach than the one I came up with?
using ORKFramework;
using UnityEngine;
namespace MyGame.Animation
{
[RequireComponent(typeof(Animator))]
public class CombatantFloatParameter : MonoBehaviour
{
[Tooltip("The name of the ORK Combatant variable.")]
public string VariableKey;
[Tooltip("The name of the float parameter on the Animator Controller.")]
public string ParameterName;
[Tooltip("Indicates that the variable is a normalized float value within the range 0.0 to 1.0 (inclusive)")]
public bool IsNormalizedValue = true;
[Tooltip("If the value of the Combatant variable will not change after initialization, then we only need to get it once.")]
public bool GetOnce = true;
private Animator _Animator;
private Combatant _Combatant;
private float _BlendValue;
private bool _IsInitialized;
private bool _RefreshValue = true;
private void Awake()
{
_Animator = GetComponent<Animator>();
}
private void Start()
{
GetCombatant();
}
/// <summary>
/// Attempt to get a reference to the ORK Combatant.
/// </summary>
private void GetCombatant()
{
_Combatant = ComponentHelper.GetCombatant(this.gameObject);
_IsInitialized = _Combatant != null;
}
private void Update()
{
// Ensure that the Combatant reference exists.
if (!_IsInitialized)
{
GetCombatant();
return;
}
// Get and store the value of the float parameter.
if (_RefreshValue)
{
_BlendValue = GetValue();
// We're getting the variable value in the Update() loop, so if we only need
// to get the initial value, we can save ourselves a call to the ORK API and just
// use the stored value
if (GetOnce) { _RefreshValue = false; }
}
_Animator.SetFloat(ParameterName, Mathf.Clamp01(_BlendValue));
}
/// <summary>
/// Get the value of the ORK Combatant float variable
/// </summary>
/// <returns></returns>
private float GetValue()
{
float blendValue = _Combatant.Variables.GetFloat(VariableKey);
// If the variable represents a normalized value, ensure it is within the valid range
return IsNormalizedValue ? Mathf.Clamp01(blendValue) : blendValue;
}
}
}
Set up the object variable on the Combatant like this:
I was just going to whip up a quick script to set that parameter on Start(), but it was marginally more work to make it usable for any float variable that you might want to convert to an Animator parameter.
For example that you can combine 2 animations with avatar mask. I use this technique for drinking potion. I make another layer with left hand avatar mask for use drinking animation that animate only my character left hand and it work perfectly.
Now, I can make a lot of animation by using avatar mask technique.
Thank you again, and please keep up your work.
Any chance someone could explain how to set MoveSetID based on a weapon equiped?
Thank you
You could probably do that in an Equip Game Event on your weapon, using a Mecanim Animation node to change the parameter.
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
This is from Part 2: Battle Mode Animations (Basic) - Sword (and Shield) Animations.
You specify the set of battle animations to use for a weapon in that weapon's properties (this is also covered in the tutorial). It's a very long tutorial, so it's easy to miss something. :-)
I was thinking about removing the original prefab and swapping it for 3 prefabs (one for body other for head and a prefab for geyser of blood). However this approach requires having additional models and I expect it to cause some problems with clothes.
Is there some other, more efficient approach than the one I came up with?
Thank you for taking the time to answer, indeed i may have missed that part.