When the box is over the button it is to activate but not activating

Good morning if someone can help me I will be grateful

I’ve been trying to solve this problem for days and I’m not sure what’s going on

Basically, I’m trying to get the button to be activated only when the box is on top of it, but when I place the box on top of the button, it doesn’t change the variable.

(sorry if there is a typo, I’m not sure how to write in English)

Add an object variable to your button like activated = 0
Then check the collision between Box and Button when this happens change the button variable to 1
Condition:
If box is in collision with button
Action: Set button variable activated = 1

Other event to invert:
Condition: Inverted: If box is in collision with button
Action: Set button variable activated = 0

Yes I just did that and still continue with the same error.

Try to change the foreach object from Button to Caixa. if doen’t work i’m going to need to see more of your other events in context to check whats going on.

Also check the collision hitboxes of both objects and the points in the Piskel related section.

I moved the object to box and went to see if it was something from the piskel… and it didn’t work

I replicated your code and the Scene Variable works but not the Object Variable. Object Variable works only for 1 button from the group, even using “Repeat for each”. Don’t know why!

Yes, it only works with one, but when you try to add more, it doesn’t work. Is it a Gdevelop bug?

At the begin of the scene you set Activado of button , try to add inside the

Condition:
Begin of the scene
→ Foreach Button
>>Action: variable activado = 0

It doesn’t work. Is it possible changing an object variable for each unique instance inside a group?

Did you try removing the Trigger Once in the last Foreach when the box and button collides?

Yes, I did! Still not working!

Looking at the original image, I think this may actually be a toggle state issue.

Can you show your current events that have anything to do with the buttons?

I really don’t know if is this what you want to achive but here is the project https://drive.google.com/file/d/1OolVG-vQ4Gn5rrW5_IdZduLqqIYhxv3x/view?usp=sharing
The events


instance botao is inside a group named bts.
I tried “caixa is in collision with bts” in Condition
and
Change the Variable Ativado of bts in Action
No success!

I’m investigating this i will update soon.

Here another this is working with groups https://drive.google.com/file/d/1WYKATXClbGOdwe8yEf7zuQnFS4ycWBWR/view?usp=sharing

Here is my project and what I’m trying to do on it, so you can have a base of what I’m trying to do

https://drive.google.com/file/d/1AGMi2Ich6WJpBQY5Bh-urvZ1mtzBs6DP/view?usp=sharing

It is for the door to open when the box is on top of the buttons

In your game when player collides with block, the variable changes to 1, but it doesn"t change back to 0 when not colliding.

I did some testing on this real quick. This works fine for me:

Here’s the preview, each box changes color and changes back afterwards depending on collision:

I don’t understand enough about object selection to know why the extra variable check is needed, especially with a for each, but it does seem to work that way.

Edit: Actually, this works for me even without the for each:

Actually this is simplified and it works fine. We were missing conditions to pass the information to the text? Is it? Because the Scene variable works without need them.