Haven't understand a bit of this:

Sorry but if one of you can explain better (for me) it will be great.

thanks, Ermes

Here I made a mini tutorial of how to implement a behavior on an object with other behaviors.
For this example add a Sprite name it Player and add to the Player the Platformer Behavior.
Then create your own Behavior and set a Property to get the Player Platformer Behavior.
And do your stuff in the new Behavior you just created.

The source code: Behaviors-Example-YouTube-tutorial.zip - Google Drive

1 Like

Thanks a lot, but for me is still like this

i don’t understand the purpose of mixing behaviours. perhaps too theoretical for me. if i can’t see the goal, i can’t understand the why.

thanks, i think i’m a lost cause on this. I usually work on small pieces of bricks, piled to make a bigger construction. This way of assembling the code upsets me.

Well the purpose is for instance to add another behaviors to the player which already has one or various behaviors

1 Like

It’s not about mixing behaviors, it’s about using them from custom behaviors. For example, say you create your own behaviors via events functions, and you want that behavior to move the object somewhere with pathfinding. Normally, you cannot since your behavior can be put theoretically on any object, including one that does not has the pathfinding behavior. This would cause a crash since you would be trying to use actions from a behavior that does not exist.

This new kind of Behavior property allows you to say “All objects that will use this custom behavior need to have the pathfinding behavior”. GDevelop will then allow you to use pathfinding actions inside of this custom behavior. If you then try to use the custom behavior on an object that does not have the pathfinding behavior, it will automatically add the pathfinding behavior to that object so that no crash is possible.

3 Likes

Thanks, really. i’ve understand something, but a very very very little.

you two are deeply inside GDevelop, for you it’s an easy matter.

i think a few on this forum will understand this feature without a specific tutorial (maybe the matter is i’m a super dumb), besides, effects on object are very appreciated!!!

thanks. Don’t waste any other time with me. :grinning:

Ermes

I look at it as being a bit like old school class inheritance, in that you can create a new behaviour that inherits, and can use, the functionality of an already existing behaviour.

@arthuro555, would you say this a simple way of viewing it?

Thanks a lot, now I understand.

It’s more like the composition than the inheritance pattern. The inheritance pattern would be if your new custom behavior had all the actions of another one and some of them may have been overwritten. Here it’s only about ensuring that other behavior is present so that you can interact with it. See this for more about composition vs inheritance.

3 Likes