playMaker

Author Topic: Calculating Direction for Unity Animator via Playmaker[SOLVED]  (Read 3264 times)

rlatndnsxo

  • Playmaker Newbie
  • *
  • Posts: 7
Hi
Recently, I've been trying to use playmaker with the Unity Animator for my 3D Character. Before I ever came across the Animator, when animating a character I've gave it a character controller and with get axis vector, control simple move, it was a nice moving character. Then I came across the Unity Animator. I've had a glimpse of the new material through the Unity 3D Animator tutorial in youtube. I've downloaded the tutorials Unity provided and saw that Unity uses scripts the measure the speed and direction of the character. Instead of using a C# script I tried to measure the speed and direction and other boolean variables through playmaker, and I've suceeded in calculating the speed through get axis vector that I already, and set fsm bool to set the value of the boolean parameters in the animator. BUT the problem was the direction. In the unity tutorial, unity go over something called a blend tree where they blend multiple animations that will be expressed depeding on specific parameters. In this case Walking Left Waking Walking Right was blended, and they were supposed to operate based on the character's direction. But Since i am having trouble with calculating the direction through playmaker actions the Blend trees I've made are completly usless. So Please help me on calculationg the direction through playmaker actions
« Last Edit: August 14, 2014, 02:07:11 PM by jeanfabre »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Calculating Direction for Unity Animator via Playmaker
« Reply #1 on: August 05, 2014, 07:27:22 AM »
Hi,

 You'll find custom samples made in PlayMaker that shows you how to work out the direction value to inject in Mecanim.


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

Study them samples and get back to me if you haven't found what you are looking for.

 Bye,

 Jean

cmonroy

  • Playmaker Newbie
  • *
  • Posts: 34
Re: Calculating Direction for Unity Animator via Playmaker
« Reply #2 on: August 09, 2014, 10:41:38 AM »
It actually is quite simple to do so...

First, you need to download some Animator Playmaker actions (available in the section Tutorial of this website, of course). Second, you need to adjust the Animator Controller for your character so it read float values between -1 and 1.

When you press the corresponding key to move left, the horizontal axis receives a value between 0 and -1, so you should turn, walk or run left whenever horizontal axis is less 0.  Do the opposite for dealing with move, walk or run right, as the horizontal axis should be receiving a value between 0 and +1 and hence your animator controller should do the left actions whenever the horizontal axis is greater than 0.

Suppose you have animations for moving 45°, 90°, 135° and 180° in each direction: what you need to do in this case is to setup a range for each motion. For example, use 0.3 for turning right 45°, 0.5 for turning right 90°, 0.7 for turning right 135° and 0.9 for turning right 180°, and do the opposite for left motions.

rlatndnsxo

  • Playmaker Newbie
  • *
  • Posts: 7
Re: Calculating Direction for Unity Animator via Playmaker
« Reply #3 on: August 13, 2014, 10:58:04 PM »
thanks alot guys  :)

I've calculated the input by using Get axis. With 2 Get Axis I've got the vertical and horizontal values that i wanted, then I transfered them to the animator parmeter using playmaker animator actions. With the parmeter it was a piece of cake having the character play animations according to the speed and direction.
Thanks for the help guys , My first post and its working great ;)