Issue with the FSM Tutorial (Solved)

This will be a bit long

I’ve gone through all the various tutorials here: GDevelop 5 tutorials - GDevelop documentation and moved on to the Finite State Machine one here: How to handle complex logic – The finite state machine (FSM) - GDevelop documentation

I’ve followed the tutorial exactly. My code looks exactly like the code in the screenshots (I added an additional debug for my variable), but for some reason the character will never enter the “walking” animation state. Nor does pressing left or right do anything.

The character will enter the “jumping” and falling animation states with no issue and will jump upon pressing up.

If I leave the “direction” variable’s initial text to “right” or “left” the character will move, but not animate. (I changed it to idle to start with to prevent the automatic movement)

Screenshots

I had to merge the screenshots because it wouldn’t let me post more than one embedded media item.

Clips

whatshappening.gif

whatshappening

If I change part of player state walking by un-indenting the part with the left and right key press (on the player walking state) I can gain control of the character, but he still will not animate. He also will move in the direction I pressed infinitely. I was also able to correct the infinite motion by adding a key release condition for both and changing the “direction” variable to “idle”, but at no point will he ever enter the walking animation state. (I can take screenshots of this if need be)

I know there was a change to how variables are handled very recently, could that have anything to do with this issue? Or am I just missing something?

Thanks

*edit: I noticed I had “w” for jump, ignore that. I was attempting to see if the issue was the direction keys. For the record, “w” or “up” both work fine for jump.

*Second edit for clarity: The issue I am having is that the walking animation will never play. The jump and fall work fine.

I don’t understand this part of the tutorial. If he’s not jumping and he’s on the floor, change his animation to falling. So his animation will be falling when he’s on the floor?

I’m wondering if that should have been inverted Player is on floor.

I was just looking at the tutorial. There’s another step, you need to click the right arrow on the bottom.

On the next page they say to use this for the jump. That previous setup was part of the tutorial.

Links
https://wiki.gdevelop.io/gdevelop5/tutorials/finite_state_machine/#the-jumping-state

https://wiki.gdevelop.io/gdevelop5/tutorials/how-to-animate-jump-fall-platformer/

That’s the next tutorial. I’m looking at the Finite State Machine one.

I’m not sure about that. Jumping and falling are both working fine. It’s just the running animation that isn’t working.

Of course falling would still work because it’s already specified earlier in the code

in the Walking state. Walking should start in the Idle state during the transition when the player uses and arrow key and the animation changes to “walking”. This should trigger the Walking state and let the player move but I’m wondering if the “walking” animation is being turned back into the falling animation because the player is on the floor when they are walking.

Also, just checking that you do have your animation named. Or maybe it’s like Keith said and it will really start working in the next part of the tutorial?

I tried swapping it, all it does is make it so that the “jumping” state is actually a falling state. Still no walking animation. Yes, the animation is named. I even tried separating left and right walking animations to see if I could call them individually without using the sprite flip. Still nothing.

Did you do the debug thing they mentioned? It might narrow it down.

Debugging information

In order to know in which state the player currently is during gameplay, create a text object and call it “debug_state”. Add it to the main scene and create the actions as below (with an empty condition), in order to display the current player state right above its head. Whenever something doesn’t function the way it should, we will know which state we have to investigate to find the error.

I think it’s all part of the same project. It might a bit vague but they used the wrong events on purpose. Either there’s still something missing or the tutorial has more steps.

Edit: I think that the first page was the end because the next page doesn’t mention the simulate jump and uses a upper case animation.

It’s weird. You can tell it’s an old example because it uses DO

Yeah, I actually added a second one for my variable so I could see what both are doing. Variable is working fine, changing as it should. The animation state one only changes on jump/fall, but stays in idle during left/right motions. I added a little gif to my original post to show what’s happening.

He’s moving left and right in the clip which should be impossible if the animation is not set to “walking” because the walking state doesn’t wake up until then. Could there be something wrong with his animation, like it’s not looped or something?

It should only be able to move if the animation is walking.

walking_state_events

No other state mentions moving except the walking state which should only happen when the animation is walking because the walking state is a sub event to the condition that the player animation be walking.

First thing I checked was the animation. It should be working fine. It’s looped. It’s set up just like the Platformer tutorial, so it shouldn’t be that.

1 Like

So, if I leave it as it is in the image you shared with the “trigger once” condition, then he won’t move at all. If I remove the “trigger once” he slides around.

What about moving the trigger once to in the same events and under Left key pressed Trigger once and Right key pressed trigger once?

Here is my file. I took out my adjustments like changing the “do once”. This is essentially the tutorial by the letter except for the additional debugger.

Still nothing. It’s wild, I looked through the templates available and the only one I could find that uses FSMs is the “not a vania” one. And there’s a lot in there. They also seem to be set up slightly differently.

Yeh I think everyone has their own method. I like to use scene variables to declare state but this method of using an object’s animation is pretty interesting. I doubt I will find anything in your project because as far as I can tell you did everything the same.

I’m new to gdevelop, but not new to programming. I’m by no means a master, but I took coding in college and I’ve spent time with rpgmaker, pixel game maker, and unreal. I wanted to get a handle on gdevelop’s FSMs since they seem like the best way to go long term, but I can’t seem to figure out this one issue. I solved everything else, just not the animation issue.

Side note, I think I’m a programming gremlin. In college, I had an issue where I could do everything by the book, perfect, and it wouldn’t work. My professor even had me copy his code and it wouldn’t work for me.

1 Like

In your main events get rid of all “include events from” except these:

In frame 0 of your walking animation, change the collision mask to go all the way down to the boundary and uncheck share same mask for all, but keep checked share for all sprites of this animation.

Because it does not realize player is on the floor when it hits animation 0, so it goes to falling, then sees it is on the floor, then goes to idle, then since you press the arrow while it is in idle it goes to walk, then at frame 0 of walk animation it thinks it’s not on the floor so it goes to falling. So now I can get him to play the animation when I use the arrow keys.

To get him to move I also had to change this:

to this

but that is probably because I’m on an older GDevelop right now and didn’t feel like starting up the pc that has the updated version. You probably won’t need to do that since your variables were working for you in the first place.

My side note is, I think you will really enjoy working with GDevelop. I am what can be described as functionally computer illiterate and what I love about GDevelop is it allowed me to take my creativity into an arena I never would have thought possible. So people like you with a solid background I notice catch on pretty quick and come up with some amazing and complex systems (I’m not on that level yet).

1 Like