UPBGE physics does not consider object deformation after starting

I’m starting using UPBGE and I’m facing an issue with the physics engine behaviour. It seems that the engine does consider the Static objects as they are when starting the game.
For example, in this model, I have a basic conveyor on a loop, 2 dynamic cubes and a diverting cube.
enter image description here

When I press “F” the conveyor goes forward. Both cubes are travelling with the conveyor which is fine. The left cube is diverted as planned (big cube is a diverter applying a force on Y axis to objects travelling through it).
But the right cube continues as if it’s still on the conveyor. It looks like that in the “engine’s brain” the conveyor is translating and not following the curve (and so being inconsistent with the display).
enter image description here

I’ve tried several ways to make the conveyor move forward :

  • Using brick logic to translate it along the curve
  • Baking the animation into action and playing it using logic nodes
  • Using a GeoNode to replace the curve modifier and driving one of the the GeoNode value from Logic Node

Nothing worked. It’s like the deformation is not taken into account by the physics engine once the game is started.

Could someone confirm it’s impossible to do what I want to do so I can stop trying. I want to see my right cube falling from the conveyor…

Blender file

bge.logic.getCurrentController().owner.reinstancePhysicsMesh()

I had the same problem :slight_smile:

bge.logic.getCurrentController().owner.reinstancePhysicsMesh(evaluated=True)

in 3.0x (if the mesh is being deformed)

1 Like

Thank you.

Should I do this on every frame ? Is this time consuming and has a huge impact on perfs ?

Anyway, thanks a lot for your help on this problem I’m stuck on since couple weeks. Not tried yet but on the paper this should exactly do what I’m expecting.

I’ve tried to do what both of you suggested in your message but this doesn’t work. The physics model is not updated and nothing changed (checked with physics vizualisation). Here is the code I execute on every frame update :

# Update the deformed mesh 

from bge import logic

def updateMeshes():
    # get controller
    cont = logic.getCurrentController()
    # get current scene
    scene = logic.getCurrentScene()
    # get a list of the objects
    objList = scene.objects
    # get object named Cube
    conveyor = objList["Cube"]
    print("Conveyor found = {}".format(conveyor))
    # get a list of the meshes on conveyor
    meshList = conveyor.meshes
    # get the first mesh
    mesh = meshList[0]
    print("Meshes found = {}".format(mesh))
    # get object that controller is attached to
    # obj Collision Bounds: Triangle Mesh
    obj = cont.owner
    print("Obj found = {}".format(obj))    
    # update obj physics mesh to suz physics mesh
    res = obj.reinstancePhysicsMesh(conveyor, mesh)
    print("Result is = {}".format(res))

The result in the console is:

Conveyor found = Cube
Meshes found = Cube.001
Obj found = Cube
Result is = False
Conveyor found = Cube
Meshes found = Cube.001
Obj found = Cube
Result is = False
Conveyor found = Cube
Meshes found = Cube.001
Obj found = Cube
Result is = False
Conveyor found = Cube
Meshes found = Cube.001
Obj found = Cube
Result is = False
Conveyor found = Cube
Meshes found = Cube.001
Obj found = Cube
Result is = False
Conveyor found = Cube
Meshes found = Cube.001
Obj found = Cube
Result is = False

It seems that the reinstancePhysicsMesh function is called with appropriate args but the result is always False.

Any idea ?

The reason is the physics Collision Bounds setting.
Turn off “Convex Hull” and before doing this uncheck “Compound” there.
Then this simple script does work here (on UPBGE 0.3):

import bge
success=bge.logic.getCurrentController().owner.reinstancePhysicsMesh()
print (success)

Hi,

This is the setting I have to my object.
image

But it still doesn’t work…

I’ll retry from scratch on a simple model…

Now the result of reinstancePhysicsMesh() is True but this does not reinstance the meshes…

Here is a link to my simple blend file https://drive.google.com/file/d/1aSdrCQk14X3uYdB637uyRZuzOHsGBQnz/view?usp=drive_link

On this screen shot, we can see that the display mesh (1) is different from the physics one (2).

change this
res = obj.reinstancePhysicsMesh(conveyor, mesh)

into
res = obj.reinstancePhysicsMesh()

Great !!!

This works perfectly now ! Thanks a lot to all of you.

it used too. but now I don’t know. either way it’s probably best to only run it when necessary rather than every frame.