playMaker

Author Topic: [Solved] Unable to alter Mechanim Parameters from FSM  (Read 284 times)

flyer10

  • Playmaker Newbie
  • *
  • Posts: 5
    • View Profile
[Solved] Unable to alter Mechanim Parameters from FSM
« on: January 29, 2019, 04:21:18 PM »
For my game I am attempting to send a float to my animation controller's parameters using the "Set Animator Float" action. But for some reason (Possibly my own stupidity) mecanim isn't acknowledging my inputs and the values remain at their starting points. e.g. The parameter "speed" in the screenshot remained at one despite the fsm sending out a constantly changing number.

This problem is also present on other data types (e.g. Bools) and I am unable to 'get' the parameter's values either.

(note that I have also tried using "Set Property" but that hasn't worked either).

I would be grateful for any suggestions.
« Last Edit: January 31, 2019, 05:43:37 AM by flyer10 »

Groo Gadgets

  • Full Member
  • ***
  • Posts: 126
    • View Profile
Re: Unable to alter Mechanim Parameters from FSM
« Reply #1 on: January 29, 2019, 06:43:21 PM »
Heya,

I'm guessing you're trying to animate a character, is there another FSM in your scene that drives your character?

Have you exposed the speed value in the inspector so you can see if the problem is the float itself?

Should be an easy problem to solve, just need a bit more info about your scene  :-)

Cheers,

Simon

flyer10

  • Playmaker Newbie
  • *
  • Posts: 5
    • View Profile
Re: Unable to alter Mechanim Parameters from FSM
« Reply #2 on: January 29, 2019, 07:03:12 PM »
Yes, It's movement is handled by a separate fsm (navmesh based movement, plan is to have animator react based on what npc is doing). If it helps there is also a third FSM pumping out a navmesh raycast.

I exposed the speed variable to the inspector and it appears to be responding correctly there so the float is fine (also verified with debug mode).

Thanks for responding

Rob

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 4120
    • View Profile
    • jinxtergames
Re: Unable to alter Mechanim Parameters from FSM
« Reply #3 on: January 29, 2019, 10:02:00 PM »
Hi.
At the bottom of you image, you can see a checkbox "Debug".
you can 'Check' that.
This way you can see the values inside the actions.

Also you do not need to loop back :

Turn of Action Sequence.
on "Set Animator Float" Check 'Every Frame'
Remove "Set Property"
Remove "next frame event"
Remove FINISHED transition.

It should look like this :



While playing you can look to the value of the speedObject inside the actions, if its changing.

Also exposing the variable (like Groo Gadgets said) can help to detect whats wrong.

To do this, go to the Variables tab, select the variable you want to see in the Inspector.
Then at the bottom there is a checkbox called 'Inspector'.
Check the Inspector Box.

then inside the fsm component you should see the variable like this :



it's possible the speed is staying 0 due to navmesh based movement but i am not sure if that is the issue.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14059
  • Official Playmaker Support
    • View Profile
Re: Unable to alter Mechanim Parameters from FSM
« Reply #4 on: January 30, 2019, 12:18:32 AM »
Hi,

 also, your sequenced state is not really optimal with its next frame action.

 instead, prefer using your action everyframe as is, it will work just fine.

 Bye,

 Jean

flyer10

  • Playmaker Newbie
  • *
  • Posts: 5
    • View Profile
Re: Unable to alter Mechanim Parameters from FSM
« Reply #5 on: January 30, 2019, 05:04:46 AM »
Navmesh does not appear to be an issue, as you can see from screenshot the float appears to be playing nice with both debug mode and the inspector (ignore the minor difference between the numbers, screenshots were taken at different times). Not entirely sure where to go from here.

Groo Gadgets

  • Full Member
  • ***
  • Posts: 126
    • View Profile
Re: Unable to alter Mechanim Parameters from FSM
« Reply #6 on: January 30, 2019, 05:16:57 AM »
What exactly does your speed float variable do inside your animator state machine?

Have you tried setting the speed value in the animator window to see if it behaves correctly?

It would be great if you could create a short video showing what's going on.

Cheers,

Simon

flyer10

  • Playmaker Newbie
  • *
  • Posts: 5
    • View Profile
Re: Unable to alter Mechanim Parameters from FSM
« Reply #7 on: January 30, 2019, 06:21:53 AM »
The speed float switches the Idle State to the walk state when it is greater than 0 and back when it is less than 0.1
Also I should have specified but when I manually alter the Speed parameter it switches around fine in the animator, it just isn't responding to the FSM.

Also I just used the following script and it is altering the mecanim parameter with no problems, so this is defiantly either a configuration problem or something is wrong with playmaker. Might have to use this as a stopgap until I can figure this out.

Quote
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class AnimatorBoolTest : MonoBehaviour {

   Animator m_Animator;
   float Speed;

   void Start () {
      m_Animator = gameObject.GetComponent<Animator>();
      Speed = 0;
      m_Animator.SetFloat("Speed", 2);

   }
}

Thanks,

Rob
« Last Edit: January 30, 2019, 06:29:20 AM by flyer10 »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 4120
    • View Profile
    • jinxtergames
Re: Unable to alter Mechanim Parameters from FSM
« Reply #8 on: January 30, 2019, 07:57:47 PM »
Hi.
I can see on your image that Action sequence is on. and the 2nd action will not run (grayed out).


When action sequence is active it will run the top action and wait till the action is Finished.
Then go to then next Action.

When action sequence is not active it will run all actions in the state (but it will still start from top to bottom, so it is still important to know what action should start 1st)

You can see on the image below there is a 'V' in the line :



This indicates that the Action Sequence is on, if its of it will be a straight line.

to toggle the action sequence you can right-click on a empty space inside the state tab, you will get a list of options.
The top one should be action sequence.


Action Sequence can't be used if you have multiple actions that are every frame based.

The 'Get Game Object Speed' does not have a every frame option, but is every frame based.

flyer10

  • Playmaker Newbie
  • *
  • Posts: 5
    • View Profile
Re: Unable to alter Mechanim Parameters from FSM
« Reply #9 on: January 31, 2019, 05:42:50 AM »
Ok, that seems to have fixed it (I had no idea that this action sequence thing even existed or how it got enabled). When I disabled Action Sequencing a second "set animator float" action appeared and after deleting that everything appears to be working fine.

Thanks for the Help

Rob
« Last Edit: January 31, 2019, 05:45:16 AM by flyer10 »