The problem with filling a large volume with small bodies. BGE/UPBGE

Hello everyone! I need help. I’m making an application in Upbge. My task is to fill the volume of a large empty object with bodies of small volume using the spawn method (or any other method). The problem is that after filling a small part of a large volume, the bodies stop interacting with the object and fall out through the object. Please tell me what to do in such a situation? (((Sorry for the mistakes, I use a translator))) :crying_cat_face: :heartbeat:

mhmm… could you upload a testfile?
because collision can be tricky:
you could use collision bounds, there are many things to adjust.

This post was flagged by the community and is temporarily hidden.

you need assign more margin for collider object and in physics setup assign collision models for you game objects or in physics step assign physics frame rate

Unfortunately I can’t attach the file here. Beginners can’t attach attachments

I think, i could find the problem. The physics engine does not have time to calculate physics(tunneling)… How to fix it?

Can u explain in more detail (mb by photo)? :sweat_smile:

spawn5.blend (904.1 KB)

Example with an array. notice that some spheres fall through both the object and the plane
https://drive.google.com/file/d/1QJij_uiLv3TaPPZnCWoPQpAh3XPfoW7b/view?usp=sharing

in picture under collision type margin - default value 0.040 - use value 0.1 or more, and if you objects not detect collision assign mass 0.100 and assign type collision - sphere, box or convex hull

objects are still falling out. I will revise the parameters of physics and the scene, maybe there is a mistake somewhere :frowning:

https://drive.google.com/file/d/1W_jf7NG7nL7EvMUEJS7VA-pGa7SJGXp2/view?usp=sharing
reduced the scale, the tunneling problem remains

i would recommend to rebuild the whole scene. so that the sphere object is on scaling 1.0.
you only need one sphere object, but add it via python. and give it a small random position, that not all spheres are spawned on the same place.
it would be easier then to make the fine tuning of the objects collision behaviour.

use something like this attached to an empty, wich is upon the bowl:


import bge
import random
G = bge.logic
sce = G.getCurrentScene()


def addSomeSpheres(cont):
    """
    this code needs to be attached to an empty with always sensor. set controller to module. 
    the module to be called: yourmodule.addSomeSpheres
    """ 

    number_of_ sheres_to_add = 100
    random_range = 10
    own = cont.owner
    for i in range(number_of_ sheres_to_add):
        obj = sce.addObject("Sphere",own,0)
        obj.worldPosition = (random.uniform(-random_range,random_range), random.uniform(-random_range,random_range), random.uniform(-random_range,random_range))

give it a try

make double walls for you collider, if you scale objects - apply scale - ctrl+A -scale its function recalculation scaling objects, if you add objects to scene need use delay - if spawn two or more objects from empty - new objects strike together and make falling out or use physic frame rate stapes equal 1-2 in default physics calculation make all five frames - if change physic step 1-2 calculation make in all frame

Thank you very much, there is no way to test your method yet, but I will check it on the weekend and write an answer :heartbeat:

1 Like