How to disable a behavior through a custom behavior

Hello!

In this example I’m trying through a custom behavior disable the character platformer behavior. The sprite have this two behaviors:

I can delete it, but I can’t disable the behavior:

And this is the event with the action of my custom behavior:

What I’m doing wrong here?

Thanks!

Are you trying to disable the platform or the platform characters.

I tested it on the character and it worked. What are you expecting to happen? I initially expected the object to drop but I realized the opposite would happen. It disabled gravity and the movement. So, it actually wouldn’t fall if it was deactivated whether on a platform or not.

I don’t know if you thought the same thing. To get the object to fall, you would need to disable the behavior and then add some force or disable the platform. Although, that would cause everything on it to fall.

1 Like

I’m trying to disable the Platfomer Character Behavior.

That’s what I wanted! When the platformer character behavior is disabled the instance stops falling. But when I press “a” the instance keeps falling, which leads me to believe that the behavior has not been disabled. If I make an event through the events of the scene the instance stops in “the air” like you said. Apparently I’m doing something wrong with custom behavior, but I don’t know what it is.

Did you test through custom behavior?

I tested it with a regular function on my phone. I added a button to make it jump, it stopped responding to the simulate jump action and when jumping it froze in place. I didn’t try the default controls or test it within a behavior. I can test it later when I’m on my PC.

1 Like

Works fine for me. I added another key so I could enable and disable it and it worked fine.

So, do you have an instance in your scene falling and when you released the key “q” it stops in the air? :eyes:

ScreenRecorderProject28

1 Like

I’ve noticed that if I delete the action in the scene events and add it back, it works perfectly.

I’m guessing it may have been the order I used to build the project… Maybe I did something illogical like add the function action first and after put the Platformer Character Behavior on the character… but I’m not sure.

If I find any way to reproduce the problem I’ll post it here. Thank you so much, Keith!!!

1 Like

You’re welcome. Sometimes that happens and it doesn’t always show an error.

1 Like

Behaviors parameters update when you open their events, so for example you added the Platformer Character behavior, but it would not detect it until you open and close the function at the eventsheet.

1 Like