playMaker

Author Topic: Using Playmaker with Mecanim (need basic help)  (Read 14412 times)

jasperPT

  • Full Member
  • ***
  • Posts: 115
  • I am a VFX Animator teaching myself to make games
Using Playmaker with Mecanim (need basic help)
« on: May 16, 2013, 12:57:39 PM »
So for the past week or so I have been trying to figure out how to use Mecanim to no avail.

After going through all the playmaker tutorials, some mecanim tutorials on the unity site and various forum posts I have learned a lot about both, but cant seem to get this to work.
I have read all the unity documentation and understand how it is supposed to work, but getting it to work with playmaker is doing my head in.


All I am trying to get to work is a simple character that goes from an idle animation to a walk animation when i tell it to move around, there seems to be no basic tutorials on using playmaker to input numbers into mecanim anywhere, so i would love it if someone could point me in the right direction or give me a clue. (there probably is some but i have just missed them)

I have the playmaker mecanim scripts installed into unity and everything is up to date.

I have attached an image that should explain my simple setup, it has all the information in my scene there.

When i hit play i can see my idle animation working, and my character moves around fine, but now i want to know how to get playmaker to set the parameter of "MovementSpeed" on my Animator while i am moving my character around.

I hope that makes sense, I know this is something extremely basic but I have been banging my head against it for a while now, and looked for forum posts relating to it however everything i come across is to do with more in depth problems and I'm just trying to get over this little bump.

Any help is much appreciated!
« Last Edit: May 16, 2013, 02:36:58 PM by jasperPT »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Using Playmaker with Mecanim (need basic help)
« Reply #1 on: May 16, 2013, 02:36:33 PM »
Hi,

First and foremost, do you have the PlayMaker Mecanim package? Is it actually what you mean by " playmaker mecanim scripts" or does that mean the mecanim samples you find on the asset store? I am asking just to make sure. Mecanim support if supported on the User Wiki:

https://hutonggames.fogbugz.com/default.asp?W1031

and use as a base the mecanim examples, you can find on the asset store for free:
http://u3d.as/content/unity-technologies/mecanim-example-scenes/3Bs

 basically, to control your "movementSpeed" mecanim parameter, you need to use the
action "SetAnimatorFloat": https://hutonggames.fogbugz.com/default.asp?W1066
 and set its animator parameter property to "movementSpeed". That's how you talk from playmaker to Mecanim.

Have you studied the examples I did with the playmaker actions? The first scene I suggest you study is "Animator controller PlayMaker". In there the Character has a "move" fsm, this is typically what you need, at least to understand and grasp the various concepts behind working with mecanim, playmaker and unity all at once :)


Also, can you clarify your idea of character animation here. It seems to me that you actually need to simply start animating your character as soon as it moves, else if you wait for a certain speed threshold, your character my look like drifting.

 If you need more clarification, let me know, it's always difficult to know what level of details to go into. So don't hesitate to point where you have difficulties.

Bye,

 Jean

jasperPT

  • Full Member
  • ***
  • Posts: 115
  • I am a VFX Animator teaching myself to make games
Re: Using Playmaker with Mecanim (need basic help)
« Reply #2 on: May 17, 2013, 04:53:09 AM »
Thanks so much for the quick reply Jean.
Yeh I meant to say Mecanim packages not scripts.

I will download those examples and have a look at your playmaker action examples now, see if i can get it figured out from there.

Ill let you know how it all goes.

Pawel

  • Junior Playmaker
  • **
  • Posts: 93
Re: Using Playmaker with Mecanim (need basic help)
« Reply #3 on: May 21, 2013, 04:19:25 PM »
Jean,

One of the items on the page from your first link it says "Follow (coming soon)" and then it lists "Animator Follow" as one of the actions... Are those two different actions?

The reason I am asking is that I have a lot of problems with the "follow" -- both the script and the PlayMaker action. In frustration I went back to the legacy animation because Follow scripts and Animator just stop working and give me error messages.

This was several months ago, so I went and tried it again today  with newly downloaded packages and same thing happens. The character does not move to the target and gives me this error:

NullReferenceException: Object reference not set to an instance of an object
HutongGames.PlayMaker.Actions.AnimatorFollow.OnEnter () (at Assets/PlayMaker Animator/Actions/Utils/AnimatorFollow.cs:57)
HutongGames.PlayMaker.FsmState.OnEnter ()
HutongGames.PlayMaker.Fsm.EnterState (HutongGames.PlayMaker.FsmState state)
HutongGames.PlayMaker.Fsm.SwitchState (HutongGames.PlayMaker.FsmState toState)
HutongGames.PlayMaker.Fsm.UpdateStateChanges ()
HutongGames.PlayMaker.Fsm.Start ()
PlayMakerFSM.Start ()


-----------------
line 57 refers to:

_animatorProxy.OnAnimatorMoveEvent += onAnimatorMoveEvent;

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Using Playmaker with Mecanim (need basic help)
« Reply #4 on: May 22, 2013, 01:37:10 AM »
Hi,

Yes, a lot has been modified since the original version. I did the follow animation scene last week, but wanted to do one more before publishing, but never had the time. since you are asking, I made it available already.

https://hutonggames.fogbugz.com/default.asp?W1031

it now feature the follow animator scene, all in playmaker and working properly.


bye,

 Jean

Pawel

  • Junior Playmaker
  • **
  • Posts: 93
Re: Using Playmaker with Mecanim (need basic help)
« Reply #5 on: May 23, 2013, 08:01:12 AM »
Hi Jean,

I tried the new Follow action with Animator and my non-biped character run away from the target instead following it. Then I tried the Mine_bot -- it did not move at all (in addition to turning sideways). Would you have a guess as to why any of those things happen?


jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Using Playmaker with Mecanim (need basic help)
« Reply #6 on: May 23, 2013, 08:18:55 AM »
Hi,

 You likely need to match the axis of your non biped to the one provided by Mecanim.

what the follow action does is simply setting the "Speed" and "Direction" of the animator component, so in your case you are likely having a 180 difference in the axis referenc of your animations.

If you can send me a sample, I can certainly look at making the action flexible on that aspect and likely implement a direction offset to account for this issue.

now if you play the demos as is, then they work."generic Skeleton PlayMaker" performs fine here. Have you not messed with the animator component or something?

bye,

 Jean
Bye,

 Jean

Pawel

  • Junior Playmaker
  • **
  • Posts: 93
Re: Using Playmaker with Mecanim (need basic help)
« Reply #7 on: May 23, 2013, 12:19:25 PM »
This probably is the case, however I was very careful to set the axis in Max with Z pointing forward: The Z numbers are positive as I move the character forward and the little blue arrow matches red compass in Animation previews.)

Here is the link to the character package:
http://www.bodytko.com/error/

jasperPT

  • Full Member
  • ***
  • Posts: 115
  • I am a VFX Animator teaching myself to make games
Re: Using Playmaker with Mecanim (need basic help)
« Reply #8 on: May 23, 2013, 05:13:12 PM »
Hi Jean,

Thanks a bunch for your help earlier, I eventually got it working, however I had to use a unity character controller as for some reason the setup you had in your scene for moving the character did not work. The inputs for mecanim still did though so it was a bit of both.
 

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Using Playmaker with Mecanim (need basic help)
« Reply #9 on: May 24, 2013, 01:50:44 AM »
Hi,

 The goal when porting these Unity samples is to match as closely as possible what they did with script and do it in playmaker. It may means sometimes not exactly whyt you want in the end. So I am glad that you got it working!

 If you think that some actions or tools should get mods, don't hesitate, I am all hears.

bye,

 Jean

Pawel

  • Junior Playmaker
  • **
  • Posts: 93
Re: Using Playmaker with Mecanim (need basic help)
« Reply #10 on: May 24, 2013, 10:06:22 AM »
Jean, did you have a chance to look at the rig I've send you -- The link to it is in my message in this tread from yesterday. This reversal of axis is something that happens in the script when it deals with a generic rig created in Max. When it goes ti idle once it reaches the target, the rig folds onto itself -- it looks like it is reversing the axis of the bones, while the mesh is not reversed...