Need help with BGE

Hi,
sorry for my english, it’s not my mother language.
I am beginning with BGE.
I have some objects (e.g. 2x half sphere and 1x cylinder). It’s similar like pipes. These 3 objects are separated (blue material on picture) and I need to remove all of them when I connect all together and close “pipe” (red material on picture). I also need it when I connect 2 half spheres or with more than one cilinders. Colors are just for link from this text.
On second example picture is separated object on the left and I don’t need to remove it until mesh will be closed - like on the right side




Thanks for everything.

I think we can discuss this here a bit better.

Do you want to replace the blue objects with the red object? (which looks to the viewer as you glued the blue objects together).
How do you determine which blue objects should be involved in this operation?
Do you plan to extend an existing object with more faces? (This is not possible with the BGE).

Red object is just glued blue objects together - as you wrote. Color is just for distinguish. In real it will be same material.
I am moving objects individualy and I need to involve all object whitch collide (or other sensor like near, ray …) with others.
No, I don’t want to editing objects anyway.

So you basically just place them that it looks like they are glued together?

It’s same like pipes - and closing them.
here is a gif where you can see it - https://imgur.com/a/zBMcK

So you move them to the right location and that’s it. Why you want to remove them? This confuses me.

Are you talking about: you want to place an extension where an end cap is? So you need to remove the cap first?

I am making something like puzzle. In tetris game we are removing complete lines, so I need something similar, but removing close area, not lines.
Area can be close with objects around, then cap doesn’t needed.

there is probably no need to remove them, to place an object you can use the ‘edit object’ actuator, but in this case I imagine you want to use python and the function is scene.addObject(). HERE is a better explanation of it’s usage.

I need to remove them. I can place object, but I need to remove, when objects are composite together.

You can do that, but may I ask why?..seems like you are just adding un-necessary steps.

to remove an object you can use the actuator ‘edit object’ or you can use python object.endObject() …be wary of it’s use though it can can cause errors and even crashes if not used correctly…

I want to do game similar like tetris, but in tetris we remove rows and I want to remove close objects.
I am able to add, move, end object, but problem is how can I remove multiple objects, which is connected together ?

That depends on how you add them in the first place.

you could create a list and store it in the ‘green object’ itself, and act according to that.
like when you have a green item, with max of 2 spots, you count the list and when there are 2 entries you loop trough the list and delete those.

so when adding the blue item you do:

  • grab the green item it’s name
  • create a list, and list.append(obj.name)put the blue item in it, same with more blue items.
  • then you do len(list) to have the number of entries
  • then create actions with it like: if len(list) == 2:
  • then you remove the caps: for obj in list: obj.endObject() list.remove(obj)

or if you parent them while adding to the green item, then you could remove them with:
for obj in own.children: obj.endObject()

here is test.blend file. It’s example. Try putting “pipes” with left mouse button and rotate it with right mouse button. there is a 4 kind of pipes (L , T , I , end) . When I connect and close them together I need to remove them and continue with placing pipes. https://drive.google.com/file/d/1owzM7ErSRGnnnTSCM30g2gDwtDcRGeAq/view?usp=sharing

it might be more efficient if you give them a property ‘free’ and when you want to delete them set this ‘free’ to True and move them some place outside of the view.
This would also require you to have quite a few already in the scene…but you would not run into trouble after starting the game and no crazy behavior when moving them to the ‘free’ zone…endObject can be unpredictable if you do not understand it…

it just seems like a simple game, which is not bad…but maybe it could be done with less complex coding as well.

Just my thinking.

OK, but I need any script how to detect closed “pipes”