Get animation name of adjacent objects

First please have a look on this

I’ve manually placed some objects with 2 important variables:

  1. xPosition
  2. yPosition

When I hover on any object my TextBox will say what it is and what are the adjacent object animations (x,y) (x+1,y) (x-1,y) (x,y+1) (x,y-1)

On the example above: If I hover on (2,2) my Text should say 2,2 animation name and adjacent animation names

I have my event that can display the hovered animation name but I don’t know how to refer to the adjacent objects

image

Please tell me how to refer to the adjacent objects’ variables.

You can’t read the values of multiple objects through GD without Javascript or some other function because you can only read the values of 1 object at a time. Otherwise it just gets the values from the oldest or first instance of the object. You need to pick them individually or store the values in a scene or global array.

If your objects already have X, Y variables then you can pick the objects by checking for objects with the X, Y plus or minus the current values. You can save the current values in variables.

I used the Create multiple copies of an object extension to test this. It automatically adds a row and column ID.

2 Likes

I’m assuming the Land objects are placed adjacent to each other with no gaps, like a grid. In which case, this works for me (Land object has 4 animations to it).

Scene editor:

image


Events:


With the result (I clicked on the middle row pink square):

image

3 Likes

It works now,
I created a scene structure with current object x and y and have blank top right left bottom variables for referring to it later


Thanks @Keith_1357 and @MrMen some parts of you guys made me know some tricks, Thank you for your time.

1 Like