init
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
|
||||
namespace VOID.Generic.Objects.Unit.Animations
|
||||
{
|
||||
[Serializable]
|
||||
public class ActionAnimation
|
||||
{
|
||||
[Required] public AnimationClip clip;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5babdf50db1449968ec3e18055128f10
|
||||
timeCreated: 1739299051
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
|
||||
namespace VOID.Generic.Objects.Unit.Animations
|
||||
{
|
||||
[Serializable]
|
||||
public class ActionLoopAnimation
|
||||
{
|
||||
public AnimationClip startClip;
|
||||
[Required] public AnimationClip loopClip;
|
||||
public AnimationClip endClip;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ab1941c1623c4d76836ab79ae93f0972
|
||||
timeCreated: 1739299081
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4202d6dc9d38401bba96287bbf88de41
|
||||
timeCreated: 1741290808
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Animations.Rigging;
|
||||
|
||||
namespace VOID.Generic.Objects.Unit.Animations.Helpers
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
[AddComponentMenu("Animation Rigging/Extract Transform Constraint")]
|
||||
|
||||
public class ExtractTransformConstraint : RigConstraint<
|
||||
ExtractTransformConstraintJob,
|
||||
ExtractTransformConstraintData,
|
||||
ExtractTransformConstraintJobBinder>
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b5141e0508a048359f47d054e1f893f9
|
||||
timeCreated: 1741290865
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Animations.Rigging;
|
||||
|
||||
namespace VOID.Generic.Objects.Unit.Animations.Helpers
|
||||
{
|
||||
[Serializable]
|
||||
public struct ExtractTransformConstraintData : IAnimationJobData
|
||||
{
|
||||
[SyncSceneToStream] public Transform bone;
|
||||
|
||||
public Vector3 position;
|
||||
public Quaternion rotation;
|
||||
|
||||
public bool IsValid()
|
||||
{
|
||||
return bone != null;
|
||||
}
|
||||
|
||||
public void SetDefaultValues()
|
||||
{
|
||||
this.bone = null;
|
||||
|
||||
this.position = Vector3.zero;
|
||||
this.rotation = Quaternion.identity;
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 93d692f5ab8246a09f9c272bab22296e
|
||||
timeCreated: 1741290854
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Animations;
|
||||
using UnityEngine.Animations.Rigging;
|
||||
|
||||
namespace VOID.Generic.Objects.Unit.Animations.Helpers
|
||||
{
|
||||
public struct ExtractTransformConstraintJob : IWeightedAnimationJob
|
||||
{
|
||||
public ReadWriteTransformHandle bone;
|
||||
|
||||
public FloatProperty jobWeight { get; set; }
|
||||
|
||||
public Vector3Property position;
|
||||
public Vector4Property rotation;
|
||||
|
||||
public void ProcessRootMotion(AnimationStream stream)
|
||||
{ }
|
||||
|
||||
public void ProcessAnimation(AnimationStream stream)
|
||||
{
|
||||
AnimationRuntimeUtils.PassThrough(stream, this.bone);
|
||||
|
||||
var pos = this.bone.GetPosition(stream);
|
||||
var rot = this.bone.GetRotation(stream);
|
||||
|
||||
this.position.Set(stream, pos);
|
||||
this.rotation.Set(stream, new Vector4(rot.x, rot.y, rot.z, rot.w));
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 31e85282774544ca90f09d7cfb94503d
|
||||
timeCreated: 1741290825
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Animations.Rigging;
|
||||
|
||||
namespace VOID.Generic.Objects.Unit.Animations.Helpers
|
||||
{
|
||||
public class ExtractTransformConstraintJobBinder : AnimationJobBinder<
|
||||
ExtractTransformConstraintJob,
|
||||
ExtractTransformConstraintData>
|
||||
{
|
||||
public override ExtractTransformConstraintJob Create(Animator animator,
|
||||
ref ExtractTransformConstraintData data, Component component)
|
||||
{
|
||||
return new ExtractTransformConstraintJob
|
||||
{
|
||||
bone = ReadWriteTransformHandle.Bind(animator, data.bone),
|
||||
position = Vector3Property.Bind(animator, component, "m_Data." + nameof(data.position)),
|
||||
rotation = Vector4Property.Bind(animator, component, "m_Data." + nameof(data.rotation))
|
||||
};
|
||||
}
|
||||
|
||||
public override void Destroy(ExtractTransformConstraintJob job)
|
||||
{ }
|
||||
}
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a3126a4f55234624853818c555c65eef
|
||||
timeCreated: 1741290841
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace VOID.Generic.Objects.Unit.Animations
|
||||
{
|
||||
/// <summary>
|
||||
/// Little hacky trick to make traversal root motion animation ALWAYS move by identical distance.
|
||||
///
|
||||
/// Requirements:
|
||||
/// 1. Attach this to start/loop/end states in animator
|
||||
/// 2. Transitions should have as small as possible exit time, less than 0.1 (0.0 would be best)
|
||||
/// </summary>
|
||||
public class MatchTargetTraversalStateHelper : StateMachineBehaviour
|
||||
{
|
||||
private bool _didMatchTarget;
|
||||
private Vector3 _startPosition;
|
||||
|
||||
public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
|
||||
{
|
||||
_didMatchTarget = false;
|
||||
_startPosition = animator.transform.position;
|
||||
}
|
||||
|
||||
public override void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
|
||||
{
|
||||
if (animator.GetCurrentAnimatorStateInfo(layerIndex).fullPathHash != stateInfo.fullPathHash) return;
|
||||
if (_didMatchTarget) return;
|
||||
|
||||
_didMatchTarget = true;
|
||||
var clip = animator.GetCurrentAnimatorClipInfo(layerIndex)[0].clip;
|
||||
var clipOffset = animator.transform.TransformDirection(clip.length * clip.averageSpeed);
|
||||
var repeat = clip.isLooping ? 100 : 1;
|
||||
animator.MatchTarget(
|
||||
_startPosition + clipOffset*repeat,
|
||||
Quaternion.identity,
|
||||
AvatarTarget.Root,
|
||||
new MatchTargetWeightMask(Vector3.one, 0),
|
||||
stateInfo.normalizedTime,
|
||||
repeat
|
||||
);
|
||||
}
|
||||
|
||||
public override void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
|
||||
{
|
||||
animator.InterruptMatchTarget(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 12a4be4ce958473d872afb306a62a3bd
|
||||
timeCreated: 1745524280
|
||||
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace VOID.Generic.Objects.Unit.Animations
|
||||
{
|
||||
[RequireComponent(typeof(Animator))]
|
||||
public class UnitAnimatorCallbacks : MonoBehaviour
|
||||
{
|
||||
public event Action<AnimationEvent> OnAnimationEvent;
|
||||
public event Action OnApplyRootMotion;
|
||||
|
||||
private void OnStart(AnimationEvent animationEvent) => OnAnimationEvent?.Invoke(animationEvent);
|
||||
private void OnLoopStart(AnimationEvent animationEvent) => OnAnimationEvent?.Invoke(animationEvent);
|
||||
private void OnPerform(AnimationEvent animationEvent) => OnAnimationEvent?.Invoke(animationEvent);
|
||||
private void OnLoopEnd(AnimationEvent animationEvent) => OnAnimationEvent?.Invoke(animationEvent);
|
||||
private void OnEnd(AnimationEvent animationEvent) => OnAnimationEvent?.Invoke(animationEvent);
|
||||
|
||||
private void FootL() {}
|
||||
private void FootR() {}
|
||||
|
||||
private void OnAnimatorMove() => OnApplyRootMotion?.Invoke();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ef0871046f0ce95458fe7d62724b7e5f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user