[SOLVED] How do I recognize a drop within a behavior

How do I…

How do I recognize when an instance of a sprite object just has been dropped utilizing a behavior? I do the same thing

  • in a behavior that is attached to the object → no result
  • in a “for each instance” loop → works as expected

The behavior is set to work with Sprite objects and the behavior requires the draggable behavior.

What is the expected result

I can utilize the behavior and don’t need to spam my scene

What is the actual result

The behavior does not work for some reason.

Related screenshots


Does not work:

Which part isn’t working? My only thoughts are you don’t need the trigger once and don’t forget to set the Boolean to false. I’d do it right before the just dropped event so it was also ready.

Thanks for your feedback.

The Boolean is set to false by default. It turned out nothing in that behavior gets actually triggered. If I put the same code into an already assigned behavior, it works as expected.

But I guess you should be able to have multiple self-written behaviors on the same type of object?

When I tried it earlier on my phone it worked but on my computer it doesn’t. Although, if I publish it, the link works in my browser but not from Gdevelop preview. There must be a bug. When I added a do step post event (under advanced) it works as expected. It also works as an action.

I wonder if the PC version is running as a post event?

edit: Now, I’m confused because it’s not working as a pre-event in Gdevelop or the web version. IDK?

Thanks for digging, @Keith_1357, much appreciated!

Does it make sense to file a bug report, WDYT?

IDK. I can’t recreate it working on the web and not my computer. Maybe I was wrong and it wasn’t triggering as a pre-event. Maybe drop is a post event. If you can recreate it, I’d say add an error report. In the meantime, maybe someone with more advanced knowledge can chime in.

According to the source code. It looks like it’s a post event. My earlier test must’ve had it as post.
(edit: this is the event to clear the drop)

Test it as a post event.

Edit: I’m confused again. because after restarting the app and creating a new project it works as a pre-event???


Edit #21212 : My earlier post event screen shot shows the post event is to clear the drag.

I feel like I’m just getting more confused. The order of the behaviors is different in my 2 projects.

This version works as a post event

This version works as a pre event

That seems to be it. The behaviors are sorted by name. If the custom behavior is first it’s a pre event. If the custom behavior is second it’s a post event.

Capitalization matters. Here “Apple” is before but lower case “apple” is after.

That is crazy! Thanks for taking the time to figure this out! :exploding_head: