Hello, I have a problem here. I can’t figure out how to keep all of the same objects in their respective positions as the main object moves. I would appreciate any help.
Give this object variable for example call it ID (you could call it anything for example HP or Tomato it does not matter but for sake of simplicity we go with ID)
Now each one you give different value in instance variables on the left
You click them and leave 1st object ID at 0 2nd you switch to 1 3rd you switch to 2 and so go on
And now in events you can Object variable ID = 0 change position to YellowBox.X()-10 YellowBox.Y()-10
Object variable ID = 1 change position to YellowBox.X()-10 YellowBox.Y()-30
Object variable ID = 2 change position to YellowBox.X()-10 YellowBox.Y()-50
Object variable ID = 3 change position to YellowBox.X()+YellowBox.Width()-10 YellowBox.Y()-10
And so go on
Are they all the same object?..as @ZeroX4 says you need to number them with a variable - i just did a video on selecting instances of the same object https://www.youtube.com/watch?v=fbwtk0u_qsU.
I think you’ll probably need to use ‘repeat for each object’ and then ‘pick all’ in the events. If the yellow one is a different object you can create points on this which you can number and then select these points with a scene variable in a repeat event.
There are so many different ways to do things in GD. If the objects used physics then you could use joints. Otherwise, the sticker behavior is very handy.
To use the sticker behavior, add the behavior to the smaller objects, place them where you want them and use the stick action to stick the smaller objects to the larger object. You can stick all of the smaller objects to a single object with one action.
Another way is to use object points with an object variable like ID. This uses a string object variable.
Add points to the object and name them with the ID that you assign to the smaller objects. This uses Point0 thru Point5
Then you just need to position the smaller objects based on the points on the larger object using the objects ID as the point name.
This sets the object ID with events. You could do it manually if you want. Since the smaller objects are identical. It doesn’t matter which object has which ID. It wouldn’t matter where the smaller objects were placed in the editor. The position action will move them to the corresponding location. If you wanted to, you could add the objects at thru events instead of with the scene editor.
If there were multiple groups then you would have to pick the relevant objects before using either method.
That actually worked perfectly, thank you so much! And thanks to everyone else who helped me out here