"The behavior is not attached to this object..."

Hey, everyone. So, I’ve been having this issue when trying to create new behaviours for my player (who possses the in-built platforming behaviour). Basically, I’ll create the player, create a new behaviour, and then continue to add the new behaviour to the player, and after that start programming in the behaviour. But when doing so and when trying to call to the player object it gives me this message: “This behaviour is not attached to this object. Please select another object or add this behaviour”. This confuses me because I HAVE added this behaviour to the object, and I can’t select another object as there are no others that posses this behaviour. I have no idea what’s going on.
1

You are in the extension/function editor, for create new behavior ?
If yes you need pass as argument a new type “behavior”, and think to fill the field of this new paremeter in the action/condition of your object.

See how it’s done in Flash extension with the behavior function “Stop”.
This article can help you. And this one too more general about extension/function/behavior

1 Like

You have to select the actual name of your player object when adding the function event to scenes or external event sheets. It’s called Object inside the behavior extension, but the object can have a different name in the scenes. It is a bit confusing at first. Just remember that objects in extensions (including object variables) are independent from scene/global objects.

On the screenshot you posted, if you are not working within the extension editor, select the player object by its name in the scene - not “Object”, which is the name of the object within your behavior extension. :wink:

Thanks for the reply. The objects name in the scene is ‘Player’ but in the Behaviours editor there is no option to select ‘Player’. Only ‘Object’. Any clue why this is?

4ian explains why that happens here:


The ‘Player’ object isn’t defined in your parameters, so it can’t be selected for any events that are within the behavior extension. What may help in your case is to add the platform character behavior to ‘Object’. It should be added as a new parameter after the default one. You’ll then have two behavior parameters with both applied to the ‘Object’ parameter.

When you go to add this behavior in scene or external events, select ‘Player’ there, and both behaviors (the platform character and your custom one) should automatically be filled in.

Alright, fantastic. New question: How exactly do I define something in the parameters? (Sorry for the questions. I’m completely new to this software).

Don’t be sorry, we all start somewhere :slight_smile:

In the behavior editor, under function configuration, click the ‘parameters’ tab and click the button to add a new parameter, as shown on this page:

http://wiki.compilgames.net/doku.php/gdevelop5/events/functions#parameters

There’s some other good information there that you’ll need to know as well.

1 Like

See also this article about making behaviors where it’s explained how to add a behavior parameter for an object: How to create a behavior for an object [GDevelop wiki] :slight_smile: