[SOLVED] Move box and the item inside a box

I’ve many boxes, with items inside them.
the player can move the boxes.

when the player push one box, i’d like to move in the same time, the box and the item inside it. For the moment, only the box moved, not the item.

item and box have the variable “number_box” (1,2,3,4…)
The variable “number_box” is the same for a item inside a box.

I try to use also javascript code, but it doesn’t run :frowning:
Can you help me, please ?

If you were doing this through events, you could simply use the “link object” event actions to link the two objects (box and item), then just use “Take all items into account” action when moving them.

Unfortunately, I don’t know how/if this is possible via Javascript. Please keep in mind Javascript is an ancillary language for GD5 that allows you to develop your own functions, rather than one that is developed with custom functions like Events, so you may have to develop the methods yourself. The GDJS documentation is available here: GDevelop JavaScript game engine

Simple. use the “Put an object around another” function to link the box with its contents. Obviously you will point to the box with the “Z order” higher than that of its content, so it is hidden.
Then you just have to move the box that its contents will move accordingly without anyone seeing it.
If you then need to separate the two objects, then use the “Separate two object” function.


these are the commands I told you