|
Post by Invector on Sept 2, 2019 15:12:29 GMT
Hmm you do that directly from the FSM editor, if it's on the Idle state, you can rum a RandomDecision to different states, and those different states run an CustomAction to play an animation.
To create this custom action is really simple, just right click into the project window > Create > Invector > FSM Behavior > New FSM Action
The script is basically 1 line to call the method Play from the animator of the controller, here is a example:
namespace Invector.vCharacterController.AI.FSMBehaviour { #if UNITY_EDITOR [vFSMHelpbox("This is a vPlayAnimationAction Action", UnityEditor.MessageType.Info)] #endif public class vPlayAnimationAction : vStateAction { public override string categoryName { get { return ""; } } public override string defaultName { get { return "Play Animation"; } }
public string _animationState; public int _layer;
public override void DoAction(vIFSMBehaviourController fsmBehaviour, vFSMComponentExecutionType executionType = vFSMComponentExecutionType.OnStateUpdate) { fsmBehaviour.aiController.animator.Play(_animationState, _layer); } } }
|
|
|
Post by Invector on Sept 2, 2019 15:12:49 GMT
ps* I will add this Action to the next update
|
|