๐ปExtending the System
In this section you will learn how to create custom animation modules.
Last updated
In this section you will learn how to create custom animation modules.
Last updated
public class AdditiveLayerSettings : WeaponLayerSettings
{
...
public override IAnimationLayerJob CreateAnimationJob()
{
return new AdditiveLayerJob();
}
}public class YourFeatureLayerSettings : FPSAnimatorLayerSettings
{
//Define your settings here, including the KRigElements.
public KRigElement myRigElement;
public override IAnimationLayerJob CreateAnimationJob()
{
return new YourAnimationLayerJob();
}
#if UNITY_EDITOR
public override void OnRigUpdated()
{
base.OnRigUpdated();
// (!) Always update KRigElements here.
// Called when a rig asset is updated/changed.
UpdateRigElement(ref myRigElement);
}
#endif
}public struct YourAnimationLayerJob
{
private YourFeatureLayerSettings _settings;
private LayerJobData _jobData;
private TransformStreamHandle _yourBoneHandle;
// Use this method for custom animation logic.
public void ProcessAnimation(AnimationStream stream)
{
}
// Use this for modifying root motion.
public void ProcessRootMotion(AnimationStream stream)
{
}
// This method is called when a new profile is linked.
public void Initialize(LayerJobData newJobData, FPSAnimatorLayerSettings settings)
{
_settings = (AdditiveLayerSettings) settings;
_jobData = newJobData;
Transform bone = newJobData.rigComponent.GetRigTransform(settings.myRigElement);
_yourBoneHandle = newJobData.animator.BindStreamTransform(bone);
}
public AnimationScriptPlayable CreatePlayable(PlayableGraph graph)
{
return AnimationScriptPlayable.Create(graph, this);
}
// Make sure to return a reference to the active asset.
// It will be used by the FPSBoneController to compute a layer weight.
public FPSAnimatorLayerSettings GetSettingAsset()
{
return _settings;
}
// Use this method to update job data when a layer is linked.
public void OnLayerLinked(FPSAnimatorLayerSettings newSettings)
{
}
// Use this method when a new weapon or item is equipped.
public void UpdateEntity(FPSAnimatorEntity newEntity)
{
}
// Use this method before the main update to gather input data.
public void OnPreGameThreadUpdate()
{
}
// Use this method to update playable data and gather game thread data.
public void UpdatePlayableJobData(AnimationScriptPlayable playable, float weight)
{
_jobData.weight = weight;
playable.SetJobData(this);
}
// Use this method when a finalized pose is required.
public void LateUpdate()
{
}
// Use this method to dispose data manually.
public void Destroy()
{
}
}