breakpoint

before change animation type
This commit is contained in:
CortexCore
2023-12-27 02:24:00 +08:00
parent 4adcd33811
commit 08cdf4d785
27 changed files with 3050 additions and 775 deletions

View File

@@ -9,18 +9,6 @@ AnimatorOverrideController:
m_Name: EntityRifle
m_Controller: {fileID: 9100000, guid: cb43cb1bf42184e45b920b0bb77554f9, type: 2}
m_Clips:
- m_OriginalClip: {fileID: 7400000, guid: ad24d1ce30ed48945a9b68be9827bc90, type: 2}
m_OverrideClip: {fileID: 8816525237524189043, guid: 8458c01c2fdae5447bf770e0341e9ccb,
type: 3}
- m_OriginalClip: {fileID: 7400000, guid: 01214145ea75a2d4b80363bba2f1a65e, type: 2}
m_OverrideClip: {fileID: -5858036045953447646, guid: 8458c01c2fdae5447bf770e0341e9ccb,
type: 3}
- m_OriginalClip: {fileID: 7400000, guid: 451f983af0dd44c419406ca1d1a0b591, type: 2}
m_OverrideClip: {fileID: 7433315730774535304, guid: 8458c01c2fdae5447bf770e0341e9ccb,
type: 3}
- m_OriginalClip: {fileID: 7400000, guid: 9bc28f4633c671a428bc05bc4b6e6a8c, type: 2}
m_OverrideClip: {fileID: 197974373799447605, guid: 8458c01c2fdae5447bf770e0341e9ccb,
type: 3}
- m_OriginalClip: {fileID: 7400000, guid: 68182865c01bbae4fb3027ea32634e3f, type: 2}
m_OverrideClip: {fileID: 541215467601930624, guid: f6c625b850088b948bf4a11919b23be2,
type: 3}
@@ -126,3 +114,15 @@ AnimatorOverrideController:
- m_OriginalClip: {fileID: 7400000, guid: 87615f3d6179d5149a4bd20a314bb372, type: 2}
m_OverrideClip: {fileID: 806794535615196031, guid: 6515624bbb09409469ca9784688969a8,
type: 3}
- m_OriginalClip: {fileID: 7400000, guid: 01214145ea75a2d4b80363bba2f1a65e, type: 2}
m_OverrideClip: {fileID: -5858036045953447646, guid: 8458c01c2fdae5447bf770e0341e9ccb,
type: 3}
- m_OriginalClip: {fileID: 7400000, guid: ad24d1ce30ed48945a9b68be9827bc90, type: 2}
m_OverrideClip: {fileID: 8816525237524189043, guid: 8458c01c2fdae5447bf770e0341e9ccb,
type: 3}
- m_OriginalClip: {fileID: 7400000, guid: 451f983af0dd44c419406ca1d1a0b591, type: 2}
m_OverrideClip: {fileID: 7433315730774535304, guid: 8458c01c2fdae5447bf770e0341e9ccb,
type: 3}
- m_OriginalClip: {fileID: 7400000, guid: 9bc28f4633c671a428bc05bc4b6e6a8c, type: 2}
m_OverrideClip: {fileID: 197974373799447605, guid: 8458c01c2fdae5447bf770e0341e9ccb,
type: 3}

View File

@@ -7,7 +7,7 @@ AvatarMask:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Pixel Upper Additive
m_Mask: 01000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000
m_Mask: 00000000010000000100000000000000000000000100000001000000010000000100000000000000000000000100000001000000
m_Elements:
- m_Path:
m_Weight: 1

View File

@@ -7,7 +7,7 @@ AvatarMask:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Pixel Upper
m_Mask: 01000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000
m_Mask: 00000000010000000100000000000000000000000100000001000000010000000100000000000000000000000100000001000000
m_Elements:
- m_Path:
m_Weight: 1

View File

@@ -107,8 +107,8 @@ BoxCollider:
m_ProvidesContacts: 0
m_Enabled: 1
serializedVersion: 3
m_Size: {x: 0.012339168, y: 0.025882503, z: 0.005909813}
m_Center: {x: -1.571532e-17, y: 0.00089429616, z: -0.0013475455}
m_Size: {x: 0.012339168, y: 0.025882503, z: 0.0035980714}
m_Center: {x: -1.4127675e-18, y: 0.00089429616, z: -0.00019167557}
--- !u!65 &8909336572364058817
BoxCollider:
m_ObjectHideFlags: 0

View File

@@ -44,13 +44,12 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1610736432900663163}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 2, y: 0, z: 2}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 3509096854786611592}
- {fileID: 5612917868120347697}
- {fileID: 261189247636088016}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@@ -206,7 +205,7 @@ NavMeshAgent:
m_GameObject: {fileID: 1610736432900663163}
m_Enabled: 1
m_AgentTypeID: 0
m_Radius: 0.16
m_Radius: 0.32
m_Speed: 3.5
m_Acceleration: 8
avoidancePriority: 50
@@ -215,7 +214,7 @@ NavMeshAgent:
m_AutoTraverseOffMeshLink: 1
m_AutoBraking: 0
m_AutoRepath: 0
m_Height: 2
m_Height: 1.6
m_BaseOffset: 0
m_WalkableMask: 4294967295
m_ObstacleAvoidanceType: 4
@@ -359,7 +358,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: c78fe9fd58f5efc4abdeb6d193bf258b, type: 3}
m_Name:
m_EditorClassIdentifier:
animator: {fileID: 673930142905110667}
animator: {fileID: 0}
rigidbodies:
- {fileID: 6212079510373085893}
- {fileID: 2627371083418363332}
@@ -468,13 +467,29 @@ MonoBehaviour:
- rid: 7707058030789525625
type: {class: Idle, ns: BITFALL.Movement.MotionBased.States, asm: BITFALL.Entities.Movement.Runtime}
data:
clip: {fileID: -4391933643253906413, guid: 6e5372ccf7beb464e965194eb4d564e8,
type: 3}
clip: {fileID: 7400000, guid: 8a914a73777e46445af7079140a911a6, type: 3}
- rid: 7707058030789525626
type: {class: Walk, ns: BITFALL.Movement.MotionBased.States, asm: BITFALL.Entities.Movement.Runtime}
data:
clip: {fileID: -203655887218126122, guid: 372c0d71272a8fb4cbfa41f52ef78994,
type: 3}
_state:
_FadeDuration: 0.25
_Events:
_NormalizedTimes: []
_Callbacks: []
_Names: []
_Speed: 1
_Animations:
- {fileID: 7400000, guid: a1a9219f954bc644d8380dc091e54347, type: 3}
- {fileID: 7400000, guid: 6fb4b5a9e960f374b966988f0807ae1a, type: 3}
- {fileID: 7400000, guid: 503e6c5caa2ffa9469ac8986db8b0a03, type: 3}
_Speeds: []
_SynchronizeChildren:
_Thresholds:
- -1
- 0
- 1
_DefaultParameter: 0
_ExtrapolateSpeed: 1
- rid: 7707058030789525638
type: {class: IdleTurn, ns: BITFALL.Movement.MotionBased.States, asm: BITFALL.Entities.Movement.Runtime}
data:
@@ -512,9 +527,8 @@ MonoBehaviour:
- {fileID: -203655887218126122, guid: 6c5cbd0e33d4ba742948bd8098f1beeb, type: 3}
- Key: Melee
Value:
- {fileID: -203655887218126122, guid: d319bd8b8d6b0274f91bddd4691c70e6, type: 3}
- {fileID: -203655887218126122, guid: cce3cdea83ca5d4488b9306b257adaa8, type: 3}
- {fileID: -203655887218126122, guid: 2af77d9f71b3eef4c908b9396adeb551, type: 3}
- {fileID: 7400000, guid: 7a068e9bd4d92a74faa3ca3c225ea7ab, type: 3}
- {fileID: 7400000, guid: 4a410aae47385784da16b5814337ad97, type: 3}
- Key: HitStun
Value:
- {fileID: -203655887218126122, guid: 82c9040f74a95ef4ca987d174540a848, type: 3}
@@ -528,14 +542,15 @@ MonoBehaviour:
- {fileID: -203655887218126122, guid: f5508ff7aab49d7438f7b931bb543fd4, type: 3}
- Key: Death
Value:
- {fileID: -203655887218126122, guid: 40e6b9a4c94e8984aa455def690dd91a, type: 3}
- {fileID: -203655887218126122, guid: 055450a83fcb47f4a8c34eb6b457d5f8, type: 3}
- {fileID: -203655887218126122, guid: a91772e7f4001264d870ee5a2cbc1048, type: 3}
- {fileID: 7400000, guid: 509a212e9c348a74997ce6f304818732, type: 3}
- {fileID: 7400000, guid: ee64f27c88f96304f91f1b945481dc2b, type: 3}
- {fileID: 7400000, guid: c1d3b61ec26c27e4a9ef066aef8e0b2e, type: 3}
- {fileID: 7400000, guid: dd782cce8d8754143ac43a11da776507, type: 3}
avatarMasks:
_serializedList:
- Key: 16
Value: {fileID: 31900000, guid: 263eecbb6a522144aac2b10bef460052, type: 2}
allowDeathAnimation: 0
allowDeathAnimation: 1
--- !u!114 &2332545226796783687
MonoBehaviour:
m_ObjectHideFlags: 0
@@ -1187,7 +1202,7 @@ PrefabInstance:
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 5964803017347144284}
m_TransformParent: {fileID: 8104504566599589718}
m_Modifications:
- target: {fileID: 6256051358093332725, guid: 2ad4d682518910847b19ed8106c0071a,
type: 3}
@@ -1212,17 +1227,17 @@ PrefabInstance:
- target: {fileID: 6256051358093332725, guid: 2ad4d682518910847b19ed8106c0071a,
type: 3}
propertyPath: m_LocalRotation.x
value: 0
value: -0
objectReference: {fileID: 0}
- target: {fileID: 6256051358093332725, guid: 2ad4d682518910847b19ed8106c0071a,
type: 3}
propertyPath: m_LocalRotation.y
value: 0
value: -0
objectReference: {fileID: 0}
- target: {fileID: 6256051358093332725, guid: 2ad4d682518910847b19ed8106c0071a,
type: 3}
propertyPath: m_LocalRotation.z
value: 0
value: -0
objectReference: {fileID: 0}
- target: {fileID: 6256051358093332725, guid: 2ad4d682518910847b19ed8106c0071a,
type: 3}
@@ -1524,7 +1539,11 @@ PrefabInstance:
- {fileID: 7613617252232372131, guid: 5f9e9216c9925af4bafec02dca8c438e, type: 3}
- {fileID: 1311415486234117464, guid: 5f9e9216c9925af4bafec02dca8c438e, type: 3}
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedGameObjects:
- targetCorrespondingSourceObject: {fileID: 2155766259452216820, guid: 5f9e9216c9925af4bafec02dca8c438e,
type: 3}
insertIndex: -1
addedObject: {fileID: 5612917868120347697}
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 5f9e9216c9925af4bafec02dca8c438e, type: 3}
--- !u!54 &797937506702059996 stripped

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -22,6 +22,8 @@ namespace BITFALL.Entites
[Inject] private IEntityOverride _override;
private readonly List<(Transform transform,Vector3 initialPosition, Quaternion initialRotation)> _initialJoint = new();
private bool _updateNextFrame;
public override void OnStart()
{
base.OnStart();
@@ -44,7 +46,16 @@ namespace BITFALL.Entites
}
}
public override void OnUpdate(float deltaTime)
{
base.OnUpdate(deltaTime);
if (_updateNextFrame)
{
EnsurePhysicsAnimation();
_updateNextFrame = false;
}
}
private void EnsurePhysicsAnimation()
{
@@ -56,13 +67,22 @@ namespace BITFALL.Entites
}
else
{
animator.enabled = _health.IsAlive;
if (_override is not null)
{
animator.enabled = _health.IsAlive || _override.IsOvering;
}
else
{
animator.enabled = _health.IsAlive;
}
}
}
private void OnOverride(bool obj)
{
EnsurePhysicsAnimation();
//EnsurePhysicsAnimation();
_updateNextFrame = true;
}
public void OnSetAlive(bool alive)
{
@@ -76,7 +96,8 @@ namespace BITFALL.Entites
x.transform.localPosition = x.initialPosition;
}
}
EnsurePhysicsAnimation();
//EnsurePhysicsAnimation();
_updateNextFrame = true;
}
public void OnSetHP(int hp)

View File

@@ -0,0 +1,19 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Animancer;
using UnityEngine;
namespace BITFALL.Movement.MotionBased
{
[Serializable]
public sealed class MotionBasedClipTransition : ClipTransition, IMotionBasedAnimationState
{
object ICloneable.Clone() => MemberwiseClone();
}
[Serializable]
public sealed class MotionBasedMixTransition : LinearMixerTransition, IMotionBasedAnimationState
{
object ICloneable.Clone() => MemberwiseClone();
}
}

View File

@@ -38,23 +38,25 @@ namespace BITFALL.Movement.MotionBased
{
if (obj)
{
_override.RemoveOverride(-1);
//_override.RemoveOverride(-1);
animancerComponent.Layers[8].Stop();
}
else if( allowDeathAnimation)
{
animancerComponent.Layers[1].Stop();
_override.AddOverride(-1);
if (animationClips.TryGetValue("Death", out var clips) is false) return;
var state = animancerComponent.Layers[8].Play(clips.Random());
state.Events.OnEnd += OnEnd;
return;
void OnEnd()
{
_override.RemoveOverride(-1);
state.Events.OnEnd = null;
animancerComponent.Layers[8].Stop();
}
//animancerComponent.Layers[1].Stop();
Play("Death",false,8);
// _override.AddOverride(-1);
// if (animationClips.TryGetValue("Death", out var clips) is false) return;
// var state = animancerComponent.Layers[8].Play(clips.Random());
// state.Events.OnEnd += OnEnd;
// return;
// void OnEnd()
// {
// _override.RemoveOverride(-1);
// state.Events.OnEnd = null;
// animancerComponent.Layers[8].Stop();
// }
}
}
@@ -69,10 +71,11 @@ namespace BITFALL.Movement.MotionBased
// }
}
public void Play(string animationName)=>Play(animationName,false);
public void Play(string animationName, bool isAdditive)
public void Play(string animationName, bool isAdditive,int layer = -1)
{
if (animationClips.TryGetValue(animationName, out var clip) is false) return;
var layer = isAdditive ? 2 : 1;
layer = layer is -1 ? isAdditive ? 2 : 1 : layer;
if (string.IsNullOrEmpty(lastAnimationName) is false)
{
_override.RemoveOverride(lastAnimationName);
@@ -90,6 +93,7 @@ namespace BITFALL.Movement.MotionBased
{
state.Events.OnEnd = null;
animancerComponent.Layers[layer].Stop();
UnityEntity.Invoke(Constant.Animation.OnPlayEnd,animationName);
if (isAdditive is false)
_override.RemoveOverride(animationName);
}

View File

@@ -16,6 +16,14 @@ namespace BITFALL.Movement.MotionBased
public interface IMotionBasedState : IEntityMovementState
{
void OnAnimatorMove();
}
public interface IMotionBasedAnimationState:ICloneable
{
}
public interface IMotionBasedAnimationClip{}
public abstract class MotionBasedAnimationState
{
}
[CustomType(typeof(MotionBasedMovement))]
public sealed class MotionBasedMovement : StateBasedBehavior<IMotionBasedState>,IEntityMovement
@@ -151,8 +159,7 @@ namespace BITFALL.Movement.MotionBased
get => Transform.rotation;
set => Transform.rotation = value;
}
Vector3 IEntityMovement.Forward => Transform.forward;
public Vector3 Forward => Rotation * Vector3.forward;
Vector3 IEntityMovement.ViewForward => Transform.forward;

View File

@@ -7,6 +7,7 @@ using AYellowpaper.SerializedCollections;
using BITKit;
using BITKit.Entities;
using BITKit.StateMachine;
using Unity.Mathematics;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Splines;
@@ -21,6 +22,8 @@ namespace BITFALL.Movement.MotionBased.States
[Inject] protected IHealth health;
protected Vector3 MotionVelocity { get; private set; }
protected Vector3 MotionAngularVelocity { get; private set; }
protected Quaternion MotionDeltaRotation { get; private set; }
public virtual bool Enabled { get; set; }
public virtual void Initialize()
{
@@ -63,6 +66,8 @@ namespace BITFALL.Movement.MotionBased.States
public virtual void OnAnimatorMove()
{
MotionVelocity = animancerComponent.Animator.velocity;
MotionAngularVelocity = animancerComponent.Animator.angularVelocity;
MotionDeltaRotation = animancerComponent.Animator.deltaRotation;
}
}
@@ -161,11 +166,21 @@ namespace BITFALL.Movement.MotionBased.States
[Serializable]
public sealed class Walk : MotionBasedState
{
[SerializeField] private AnimationClip clip;
[SerializeField] private LinearMixerTransition _state;
private AnimancerState _playingState;
private float rot = 0;
public override void OnStateEntry(IState old)
{
base.OnStateEntry(old);
animancerComponent.Play(clip,0.1f);
_playingState = animancerComponent.Play(_state);
}
public override void OnStateExit(IState old, IState newState)
{
base.OnStateExit(old, newState);
_playingState = null;
}
public override void OnStateUpdate(float deltaTime)
@@ -198,18 +213,44 @@ namespace BITFALL.Movement.MotionBased.States
public override void UpdateRotation(ref Quaternion currentRotation, float deltaTime)
{
base.UpdateRotation(ref currentRotation, deltaTime);
var pathRotation = currentRotation;
var lerpRotation = currentRotation;
var direction = agent.steeringTarget - agent.transform.position;
if(direction.sqrMagnitude>0.1f)
{
direction = Vector3.ProjectOnPlane(direction, Vector3.up);
currentRotation =
pathRotation = Quaternion.LookRotation(direction);
lerpRotation =
Quaternion.RotateTowards(
currentRotation,
Quaternion.LookRotation(direction),
pathRotation,
360 * deltaTime
)
;
}
if (_playingState is not null)
{
var dir = pathRotation * Vector3.forward; //位置差,方向
var dot = Vector3.Dot(movement.Forward, dir.normalized);//点乘判断前后dot >0在前<0在后
var dot1 = Vector3.Dot(movement.transform.right, dir.normalized);//点乘判断左右: dot1>0在右<0在左
var angle = Mathf.Acos(Vector3.Dot(movement.Forward.normalized, dir.normalized)) * Mathf.Rad2Deg;//通过点乘求出
angle = dot1 > 0 ? angle : -angle;
var clamp = Mathf.Clamp(angle/45, -1, 1);
rot = Mathf.MoveTowards(rot, clamp, 8 * deltaTime);
_state.State.Parameter =rot ;
//Debug.Log($"angle:{angle} dot:{dot} dot1:{dot1} clamp:{clamp}");
}
currentRotation = lerpRotation;
}
}

View File

@@ -32,6 +32,10 @@ namespace BITFALL.Entities.Player.Movement.States
public override void AfterUpdateMovement(float deltaTime)
{
if (knockdown.IsKnockdown)
{
characterController.TransitionState<Knockdown>();
}
if (knockdown.IsKnockdown is false && characterController.ExpectParachute.shouldBe)
{
characterController.TransitionState<Parachute>();
@@ -216,6 +220,7 @@ namespace BITFALL.Entities.Player.Movement.States
public override void AfterUpdateMovement(float deltaTime)
{
base.AfterUpdateMovement(deltaTime);
if (characterController.CurrentState != this) return;
switch (characterController.ExpectRun.shouldBe,characterController.ExpectCrouch.shouldBe)
{
case (_,true):