[Solved, NOT bug] - Wrong X,Y when Object in Group

Hi,

:exclamation: When an object is in a group, I can’t correctly reference the X and Y coordinates of that object.

This is the practical example:

I’m working in a basic platformer for test purposes. I have many objects named portal_01, portal_02, portal_03… etc, and all of them are in a group. Now, I want to “teleport” my character to the coordinates of one of this portal objects but every time I try to do that, the character is “teleported” to the 0,0 coordinates, that means the game is interpreting the coordinates portal_01.X(), portal_01.Y() (for example) as 0,0 even if this is not true (by now I have made a lot of testing and the game works fine if the “destiny” object is not in a group, but that means a lot of extra work declaring conditions, events and actions).

Can you include your game with your post? I’m using groups all the time and they always work fine. What I’m wondering is how you are selecting just one object from the group (so that GD knows which object to reference the X & Y position from).

Oh, I’m making a direct call to this objects… 's NOT like I was iterating through an array.

Yeah, well, I can’t… by now, my game is HUGE on resources and like I said to you on another post, my “Save all the resources to the same folder” option is not working well, but I have two good news:

  1. I find a wrap around to make this works.

  2. I took the time to made I little tiny ugly game example to show you the bug 'cuz I’m so f***ing awesome .

The example have two scenes “bug” and “bug wrap around”, obviously one works and the other don’t. The differene of code economy between the two scenes is just one line in the events window, but it can be more in more complex games. The “bug” scene is a implementation of the group behavior management showed in the html5 “Buttons” example.

So, compare the event structure, run the two scenes and tell me if you meet the bug:
bug_example.7z (39.5 KB)

You don’t need any extra lines of code. All you need to do in this case is make sure that “Down key is pressed” is not a sub-event, but is its own event. If you don’t believe me, try deleting the extra line of code and put the down key event as not being a sub event (in the scene ‘bug’) and you will see it all is working.

Thanks for the advice but if you check the other scene in that project, you’ll se I’m already doing exactly what you’re telling me… but in any case it still requires more lines of code… compare the events in the TWO scenes and you’ll see what I mean.

I don’t know if it is a bug, but of course is a logic problem about the reference object (event object reference and group object reference).
Since:
-If you add the action “Consider all objects portals” in the event that checks the key Down press there is no problem.
-The only objects that return position 0;0 (and apparently doesn’t exist) are portals in the same group portals that are not named in the sub-event condition: In the sub-event with the condition “player is in collision with portal1”: portal1, player and blocks has no problems, but portal2 and portal3 apparently doesn’t exist.

YES, you’re absolutely right. It’s a logical error by mi side. Thanks for responding.