playMaker

Author Topic: Set All Animator Bools  (Read 1437 times)

sandEboy

  • Playmaker Newbie
  • *
  • Posts: 39
    • GraspTech
Set All Animator Bools
« on: April 08, 2023, 05:43:51 AM »
Same as the regular set animator bool but takes all bools of the animator at once and either set true or false.
I need this PLEASE. So tedious having to add a set animator bool action and readjust every state to take that one into account every time I update the animator.
Please make this action.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Set All Animator Bools
« Reply #1 on: April 08, 2023, 08:44:25 AM »
Hi.
A single action would not be good for performance. since you would need to get the names of each parameter, every time you would use the action.

You can preset an Array (List) with the parameter names.
Then use Array (List) Get Next.
and on the next state set it true/false then transition back to the state with the array (List) get next.

and connect the done transition to continue

sandEboy

  • Playmaker Newbie
  • *
  • Posts: 39
    • GraspTech
Re: Set All Animator Bools
« Reply #2 on: April 08, 2023, 08:56:45 AM »
That would disrupt my entire workflow and structure of animating my characters since the transitions go directly from say "run forward" to "strafe left" or "jump" for example, where it has a "set animator bool" action to false for every other animation in the animator component and one that sets true for the current animation I need played. Performance has never been an issue for me in that regard. What has been is having to go through every single state to add a set animator false action for every new animation I add to the animator component. I guess since there will eventually be a limit I should be fine to just copy paste that entire list of actions to every state and set the one I need true but if performance isn't an issue for me it sure would be nice to have that one action that I wouldn't have to go back to tinker with every time.

https://answers.unity.com/questions/1241717/set-all-bool-parameters-in-animator-to-false.html

This link shows exactly what I need for better understanding.
« Last Edit: April 08, 2023, 09:03:40 AM by sandEboy »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Set All Animator Bools
« Reply #3 on: April 08, 2023, 01:49:31 PM »
Hi.
The action below will do the loop in 1 action, you still need to preset the parameters references in an array.

You can use Get Fsm Array on start.
so you only need to update 1 array

its also possible to add a 2nd array with the bools, this way you can set each one individual true or false.
if that's useful for you, let me know
« Last Edit: April 08, 2023, 01:55:14 PM by djaydino »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Set All Animator Bools
« Reply #4 on: April 08, 2023, 02:02:07 PM »
From what I understand you have a bool for each animation?

If so, I don't think that this is a good way to do this.
if you use sprite base you could use 'Animator Play' instead

other possibility might be using an int instead of bool

sandEboy

  • Playmaker Newbie
  • *
  • Posts: 39
    • GraspTech
Re: Set All Animator Bools
« Reply #5 on: April 08, 2023, 07:50:42 PM »
Yes I have a bool for each animation in the animator component. It is a 3d project with a rigged character.
I think an alternate way to solve my problem is maybe an action that resets the animator component which would mean all bools are set to false. But I'm not sure if it would affect the animation blending as a new animation bool is set to true. Thanks for the action and suggestions, I'll see how I can implement it.

Edit: Wow... this was exactly what I needed... You're a genius. Thank you so much!
« Last Edit: April 08, 2023, 08:01:30 PM by sandEboy »