playMaker

Author Topic: 2.5D sprite defaulting to "down idle" position  (Read 1993 times)

Levijohnson3

  • Playmaker Newbie
  • *
  • Posts: 6
2.5D sprite defaulting to "down idle" position
« on: January 26, 2020, 12:29:00 PM »
Hey all,

I'm new to Playmaker. But in the past few weeks I've been learning a little bit here and there. But something that's come to my attention is that Hutong/Playmakers tutorials are ANCIENT and very limited. The website's forum and sign up process is a good example... but regardless, I found this place eventually. I've been following along with this guys tutorial on youtube on creating a Player character's movement using sprite sheets and blend trees and translating them into a 3rd person system like in "Paper Mario". So far I've been fine, converting his coding sections into playmaker sfm hasn't been too hard. But eventually in the video he talks about this: ...In the time stamp, the player character always seems to go back to the "idle down" sprite when there's no input... I can't for the life of me figure out how to get the blend tree sprites to stay as the last direction pressed in terms of playmaker sfm. Any help would be appreciated!

I've attached the 2 states i have that have got me this far.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: 2.5D sprite defaulting to "down idle" position
« Reply #1 on: January 26, 2020, 01:09:23 PM »
Hi.
I had a quick look on the video and i believe that ist all handled in the animator.

If so you can just use a fsm with a single state and set this :



for speed you can use 2D or 3D, depending your needs

oh btw the timestamp does not seem to work.
For others that want to have a look the timestamp is on 19:02

Thore

  • Sr. Member
  • ****
  • Posts: 480
Re: 2.5D sprite defaulting to "down idle" position
« Reply #2 on: January 26, 2020, 01:53:28 PM »
Welcome. The general setup is like Djaydino shows. First have the character move about and pass on the speed/input to the animator. That is, you don’t use an idle state at all.

Which animation state is shown last is configured in the blend tree setup. So you have to study that more closely. Playmaker only tells the animator the direction, but you need to be careful what you pass on. If you want animations to follow the actual final speed, you pass on the movement speed. But in the video, as far as quickly saw, the range for the blend tree is normalized (i.e. 0—1) so you probably pass on the input directly.

Levijohnson3

  • Playmaker Newbie
  • *
  • Posts: 6
Re: 2.5D sprite defaulting to "down idle" position
« Reply #3 on: January 26, 2020, 05:23:38 PM »
Thanks, I feel like you've helped me, but if you could run that all by me again... I'm having a hard time understanding some of what you mean. I used the state he used in the image... but its not working. I had deleted what I had and tried his fsm and it didn't move at all not even idle... should I connect it to what I already had? Should I create another walking fsm separately? I was running a Character controller on it and not a Rigid Body, does that change anything? Thanks, sorry for being a little slow on the uptake!

Thore

  • Sr. Member
  • ****
  • Posts: 480
Re: 2.5D sprite defaulting to "down idle" position
« Reply #4 on: January 26, 2020, 07:17:51 PM »
Oh, I see. I think Djdino forgot to set the speed value.

Basically. You need one state with:

1) Get axis (as configured in Unity’s input manager), usually “Horizontal” and “Vertical”. That means, two actions. Every frame. They get values from -1 to 1, and 0 means no input (or stick middle position).

2) When you would set the axis to speed, you have two issues: first, your character would move only with speed 1 (as that’s what the axis return). So you need to multiply the value with your desired speed.

But there’s another problem and that’s the character would move faster diagonally, because the vector 1/1 (i.e. moving top right) is greater than 1. To solve this, you need to normalise the vector first so it’s never greater than 1.  There is apparently an action for this (if not check forum/ecosystem, which is a free add-on browser to install extra actions).

I guess to use this, you would actually first write the axis float variables into a vectorXY (Z) so you have a vector, then you send this vector into the normalize vector action to get a clean, good vector that is diagonally correct, too.

3) Then you need to multiply the direction with your desired movement speed. Say, 5. I guess there’s a vector multiply, or you might convert the values back to floats.

4) Now you have a good value coming out, and that goes into e.g. set velocity or set speed (?) as in DjayDino’s example. But you would SET it.

5) all of this is in a single state and every frame. Your character should move now.

6) then, finally, to also play the correct animation, set animator float and use your original axis values. You can check in the animator parameters if the values are coming in there correctly. So if the animation is not correct yet, you know you need to fix something in the blend trees etc.

Some of this seems complicated at first, the core idea is this: you get the input into a value and then you set it into an action that moves the character around. And independent of this, you also set the value into the animator so it “knows” when you move.
« Last Edit: January 26, 2020, 07:20:37 PM by Thore »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: 2.5D sprite defaulting to "down idle" position
« Reply #5 on: January 29, 2020, 09:14:29 AM »
Hi.
Sorry, yes i did not add 'Set Speed' as i am so used now to do this in a different fsm.

On a different fsm i use 'Get Fsm Float' for horizontal (and vertical if needed) result and then do set velocity

Levijohnson3

  • Playmaker Newbie
  • *
  • Posts: 6
Re: 2.5D sprite defaulting to "down idle" position
« Reply #6 on: January 29, 2020, 11:22:44 AM »
Thanks, I'm very close to this being finished, but something in my speed variable is messing up. Any time I set speed in any action, it bugs out from 0 to 6.971065E-21. I can't get the animation to play at all because of this. Any idea why this is?

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: 2.5D sprite defaulting to "down idle" position
« Reply #7 on: January 29, 2020, 11:25:05 AM »
Hi.
Hard to tell if we can't see the fsm setup :)

Levijohnson3

  • Playmaker Newbie
  • *
  • Posts: 6
Re: 2.5D sprite defaulting to "down idle" position
« Reply #8 on: January 29, 2020, 11:37:33 AM »
Here ya go

Levijohnson3

  • Playmaker Newbie
  • *
  • Posts: 6
Re: 2.5D sprite defaulting to "down idle" position
« Reply #9 on: January 29, 2020, 11:40:04 AM »
I set the "Set Velocity" to speed tinkering around. It's on horizontal and vertical.

He moves around but is still stuck in his idle and still defaults to down idle when no input in there.
« Last Edit: January 29, 2020, 11:41:36 AM by Levijohnson3 »

DanielThomas

  • Beta Group
  • Full Member
  • *
  • Posts: 150
Re: 2.5D sprite defaulting to "down idle" position
« Reply #10 on: January 30, 2020, 08:54:49 AM »
The answer I gave on discord,  for anyone interesting: Using the tutorial video posted, he just need to make sure the animation floats 'vertical' and 'horizontal' isn't updated when input is 0,0. (which the tutorial does with a simple if-statement, you can see it at 20:04).

My suggestion was to have two states that check the input vector, and depending on if it's zero or not goes to an Idle or Move state where only the Move state updates the animation floats of vertical and horiztonal - which should emulate the tutorial video.

Levijohnson3

  • Playmaker Newbie
  • *
  • Posts: 6
Re: 2.5D sprite defaulting to "down idle" position
« Reply #11 on: January 30, 2020, 09:55:45 AM »
Would you happen to have a visual? I'm a complete beginner and I'm still having the same issue as I was with you on discord, being that my speed variable seems to be glitching out from 0 to infinity any time I have it mentioned in an action. So even if I did it your way, it wouldn't work. Sorry, I just felt like I was hassling you on Discord.

DanielThomas

  • Beta Group
  • Full Member
  • *
  • Posts: 150
Re: 2.5D sprite defaulting to "down idle" position
« Reply #12 on: January 30, 2020, 10:50:29 AM »
Ok, that's not how you explained it. You said everything was working except the face direction when Idle.
If you pack and send over(in discord) the scene+animator+animations+sprites I can have a look.