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.
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).
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…
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.
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):