There were several things. First, the file you sent me the behavior wasn’t assigned to char. It turned out the behavior was assigned but it was hidden. For some reason the behavior and function were both set to private. I made them public.
There also wasn’t an obstacle object or an action to trigger the function. So, I added both. You need to have an action that triggers the function and supplies the name of the obstacle object.
I made two scenes to compare my behaviour without closing and open another project.
The character in the Untitled scene is the one where I created the events, the one with the water.
In the scene2 there’s another character which I tried to create the behaviour and I attached it to the character Char. In the Untitled scene2 there’s no water.
Which scene is causing the problem? As I said, there were minor issues with the scene with the behavior. The function in the behavior has to be called from the scene. The function needs to be visible to be able to be added. The one direction was changing y() instead of x().
I initially thought the behavior wasn’t attached but that was only because the behavior was set to private.
edit: I added a water object because the function needs an object to test against
There doesn’t seem to be an easy way to control other objects from a behavior. Just like a function they’re independent or self-contained.
You can use functions within a behavior, it’s the use of other objects that needs an outside function call or the other objects also have a have a behavior.
Most behaviors/extensions seem to use a function when using additional objects. Except for the path finder or platform behaviors which use separate behaviors. I guess you could have 2 behaviors, one for the player and one for the obsticales. Or use the same behavior and the option to choose whether it’s a player or obsticales sort of like the physics havior has a static state. I don’t know how objects with behaviors communicate with each other. I’ll have to look into that. I know with Javascript, you can pick objects by their name using a string.
I’m not sure how the physics objects interact with other objects that have the physics behavior. Although , even it requires the other objects to have a behavior.