BGE: Getting rigged door mesh to update for collisions I set off to create a rigged door, thinking a single mesh object with moving parts should be easier to manage than having each part as a separate object - especially once there are a large number of doors in a level and some doors have many animated parts.

If the physics calculations turn out to be too slow I will reconsider this approach, but I want to test it out. Besides, knowing how to update the physics mesh will be useful for many other situations too.

Here is my test scene with a player object (Character collision type) that falls onto a trap door mesh object. Collision with the mesh object triggers a Message to its parent armature and an Action Actuator plays the rigged animation of the door opening. This part is working fine.



From what I've read, when a mesh deforms, if collisions are required it must be updated using reinstancePhysicsMesh() 

Official documentation on it is here, but to be honest I don't understand all of what's written there. For example, it seems that arguments are optional, but are they optional in my case? Not sure.

I tried writing a simple script for this, but I believe my syntax is wrong because the player object does not fall through the trap door, and as you can see from the physics debugging visualization, the physics mesh is not updating.



Logic:



Script:

import bge
cont = bge.logic.getCurrentController()
own = cont.owner

char_coll = cont.sensors["CharColl"]

if char_coll.positive:
    print("Character collision detected")
    own.reinstancePhysicsMesh()
After some consideration, I've decided that my original approach is not a good way to make door rigs, even if reinstancePhysicsMesh() can be made to work for this use.

I am posting a partial answer, with what I believe to be a better way to make rigged doors. This solution assumes that armature deform is not a requirement for the doors.

The answer is partial because it does not address how to use reinstancePhysicsMesh(), but maybe someone else can post an answer addressing that aspect, or maybe it should be a separate question.

Essentially, all I did is separate the mesh into 2 objects, remove the vertex groups, and parent the entire door objects again from Pose Mode. No armature deformation, since the door panels are completely rigid. 





I realize this contradicts my original statement about wanting a single mesh, but I've realized 2 things that make managing doors with multiple parts easier:


If the parent armature of the door and the door mesh objects each have their origins at the same location it's easier to keep track of them. Grouping them together would also be a good idea, of course.
Writing the game logic on a single mesh object and then separating its parts can save you from having to write duplicate logic.


These things become obvious once thought through and tried. Together they eliminate any reason for an aversion to multi-mesh door rigs. Managing large numbers of doors each with multiple mesh objects is actually not so difficult to organize. This brings me to a third point:


Texturing as a single mesh and then separating into multiple mesh objects can simplify production too.


tl;dr I believe this approach is totally sufficient unless you have a door made of meat or something, in which case we're back to needing reinstancePhysicsMesh(). For rigid doors, this covers it.