Distance detection not working with a variable

The problem is in the code labelled rendering. For some reason the second line in the second action is getting activated when it shouldn’t, causing the moving lava behind the player to not render in, and thus not move. I know that it is the second action since it worked after I deleted it.

The actions are getting actioned because the conditions are met. Are you referring instead to the conditions?

Is Everything a group? If it is, then the problem you have is that some object in the group Everything will have a distance not below it’s RenderedAt value.

Sorry for the confusion, what I am saying is that the action shouldn’t be getting set off. Everything is a group, but even when I put the code in a for each object loop it doesn’t work

Sure, most likely because you’re including the object that triggers the event conditions when you loop through all the object?

I’d suggest an old school debugging technique, and create a text box on the screen, and set it’s text to Everything.ObjectName() in the action of the 2nd event, and see what object triggers it.

I’m not sure I understand. Why wouldn’t it work in a for each object loop? The logic is, for each everything that is further than it’s rendered at variable, it will unrender that specific object. If it were activating the actions for all objects then the floor would disappear as well right?

Have you tried working out what objects trigger the event? That may give a clue to what’s going on. It could be a logic error or it could be a GDevelop characteristic.

Uh, I found the problem. I don’t know why but having the player inside of the everything group is what was causing the problem. It works fine now, thanks for the help : )

Well, that makes 100% sense. If the player is in the everything group, it is 0 pixels from itself.

When testing against an object group that the object is a member of, the current object isn’t somehow excluded from the test, the engine has no way to know you want that.

You could always add something like a “Compare two strings” condition, add Everything.ObjectName(), use the != (not equals) qualifier, and then put your player object’s name in the other field. However, removing it from the group solves that as well.

1 Like

That actually made me lol (the first line from @Silver-Streak explains why). So it is literally everything. Good to see you got it sorted :+1:

I would’ve thought that having it in a for each object loop would have fixed that though wouldn’t it? Since it is running the code for every individual object in the group (including that player), I’d have though that having the player in the class would only effect the player and not external objects, but maybe I just don’t know how for object loops work (Which is quite possible)

As far as I know, referring to an object group always includes all members of the group, no exceptions are made regardless of event type. So even in a foreach, if you are testing against a group that the object is a member of, the object itself will still be in that list.