Move gui box with cursor and merge gui box when collapese

I like to build this kind of game

  • the base object move with the cursor in bottom of the screen

  • object 1 fall from top to bottom

  • object 1 collapse with the base object, object 1 need to link with the base object and move with the base object

  • the next object fall top to bottom and when it collapses with the object 1 it needs to merge with both object1 and base object

Now I have a problem with

  1. moving the base object with the cursor,

  2. Merging objects after the collapse

Are there any example I can refer to. please help me.

Fankly, I think you should start with doing the tutorials, as these questions are quite simple and if you had done a few of the tutorials I am sure you can figure it out yourself. :slight_smile:

That said here are some pointers, but still - do the tutorials.


You should read up on input

At the most basic of this you only need to set the position of your game object at your mouse. Now this would make a very jerky movement so this is probably not 100% what you want.

function on_input(self, action_id, action)
  if action_id == hash("touch") then
    gui.set_position(gui.get_node("player"), vmath.vector3(action.x, 0, 0))
  end
end

This could probably be sovlved easily with paranting

1 Like

I have an example of something quite similar, although the base doesn’t move:

If you were to adapt my example and have the ground move as well you’d most likely need to use game object parenting as @Jerakin suggested.

1 Like

Thanks for your help @Jerakin and @britzl.