direct trigger of animation via animator

This commit is contained in:
Chikashi Miyama 2019-11-01 15:38:30 +01:00
parent 86a6c66405
commit f0f25058b8
2 changed files with 8 additions and 62 deletions

View file

@ -10,8 +10,7 @@ AnimatorState:
m_Name: OrangeBoxAnimation1
m_Speed: 1
m_CycleOffset: 0
m_Transitions:
- {fileID: 3650698134756784025}
m_Transitions: []
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
@ -41,7 +40,7 @@ AnimatorController:
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_Controller: {fileID: 9100000}
m_AnimatorLayers:
- serializedVersion: 5
m_Name: Base Layer
@ -65,8 +64,7 @@ AnimatorState:
m_Name: Idle
m_Speed: 1
m_CycleOffset: 0
m_Transitions:
- {fileID: 1678429242150936225}
m_Transitions: []
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
@ -82,56 +80,6 @@ AnimatorState:
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
--- !u!1101 &1678429242150936225
AnimatorStateTransition:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions:
- m_ConditionMode: 6
m_ConditionEvent: Moving
m_EventTreshold: 1
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: -985118024630667659}
m_Solo: 0
m_Mute: 0
m_IsExit: 0
serializedVersion: 3
m_TransitionDuration: 0.25
m_TransitionOffset: 0
m_ExitTime: 1
m_HasExitTime: 0
m_HasFixedDuration: 0
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1101 &3650698134756784025
AnimatorStateTransition:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions:
- m_ConditionMode: 2
m_ConditionEvent: Moving
m_EventTreshold: 0
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: 1370166835903048213}
m_Solo: 0
m_Mute: 0
m_IsExit: 0
serializedVersion: 3
m_TransitionDuration: 0
m_TransitionOffset: 0
m_ExitTime: 1
m_HasExitTime: 0
m_HasFixedDuration: 0
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1107 &5132364533452248602
AnimatorStateMachine:
serializedVersion: 5
@ -143,10 +91,10 @@ AnimatorStateMachine:
m_ChildStates:
- serializedVersion: 1
m_State: {fileID: 1370166835903048213}
m_Position: {x: 340, y: 60, z: 0}
m_Position: {x: 280, y: 120, z: 0}
- serializedVersion: 1
m_State: {fileID: -985118024630667659}
m_Position: {x: 340, y: -30, z: 0}
m_Position: {x: 350, y: 30, z: 0}
m_ChildStateMachines: []
m_AnyStateTransitions: []
m_EntryTransitions: []
@ -154,6 +102,6 @@ AnimatorStateMachine:
m_StateMachineBehaviours: []
m_AnyStatePosition: {x: 50, y: 20, z: 0}
m_EntryPosition: {x: 50, y: 120, z: 0}
m_ExitPosition: {x: 520, y: 140, z: 0}
m_ExitPosition: {x: 520, y: 130, z: 0}
m_ParentStateMachinePosition: {x: 800, y: 20, z: 0}
m_DefaultState: {fileID: 1370166835903048213}

View file

@ -6,15 +6,13 @@ namespace cylvester
{
[SerializeField] private Animator anim;
private float speed_ = 1.0f;
private static readonly int Moving = Animator.StringToHash("Moving");
private static readonly int OrangeBoxAnimation1 = Animator.StringToHash("OrangeBoxAnimation1");
private bool trigger_;
public void OnTriggerReceived()
{
anim.speed = speed_;
anim.SetBool(Moving, false);
anim.SetBool(Moving, true);
anim.Play(OrangeBoxAnimation1, -1, 0f);
}
public void OnStateChanged(IStateReader currentState)