Prevent player from unmorphing

Hello !
I’m trying to prevent my player to go from the “ball” state to the “crouch” state when it’s a tiny space.
I added a point above the sprite named “Collision” and added some event that should work, but I still manage to un-crouch when i’m in a small space where I initially don’t have the place to unmorph…

Hi @Sa-x,

I see in your events, if animation = morph then change animation to morph. This doesn’t make sense. The result of an action should be different than the condition.

This obviously won’t fix the issue, but I can’t guess what’s the problem because there isn’t enough context from the screenshot and your description.

1 Like

Yes because if the player press UP then the animation will change to Crouch but I want to prevent it so I did that… But the event of the crouch are thoses :

I still don’t understand your events. But I’ll try to give you a suggestion on how you can implement this.

1st instead of copying the code twice for left and right, you can utilize an object variable string on the player. I’ll call it “dir”. And add these actions to your controls setup events:

"left button" pressed → set "dir" = left
"right button" pressed → set "dir" =  right

Also add another variable called “state”.
Add a condition to the running animations in the controls setup, “state” = uncrouch.

Now for the couching, I assume the “collision” point is to test if there’s a tile above the player while crouching (correct me if I’m wrong). One thing to note is that testing for “(inverted) point inside tile” will always return FALSE if there are more than 1 instance of tile (even if the point is inside a tile) because the point is NOT inside ANY ONE instance of tiles.

To work around this, you can set-up your events like this ( ↳ represents a sub-event):

"crouch button" pressed → set "state" = crouch

"uncrouch button" pressed → set "state" = uncrouch
  ↳ point inside tile → set "state" = crouch

"state" = crouch
  ↳ "dir" = left → set animation = crouch_left
  ↳ "dir" = right → set animation = crouch_right

This is the basic logic, you’ll need to implement this in your code adding other necessary actions and conditions, like trigger once, player is on ground, variables etc…