Update collision bounds upon scale in game

I have a sensor that scales in game using animation. However, the collision bounds do not appear to update in game? When I run it with physics vis on, it still shows the exact same physics box even though it has changed size. How do I force an update?

Is this possible with an edit object “replace mesh” with a smaller mesh? What is the best way to do that? I currently have box collision bounds, will that have to be changed to triangle mesh, and does that negatively impact performance?


I do not discover problems with a scale action. What kind of animation are you using? Object scale, Shape Action, Armature Action.

I have attached a link for download… I am attempting to do a crouch action, and have my body physics sensor box scale/move when hitting the “J” key, and it doesn’t update the collision bounds.


Apparently it is because the parent object is a dynamic physics object? Unsure how to make that work?

If you are using a shapekey action you’ll need “reinstancePhysicsMesh” to update te mesh. Make sure you only update the mesh when the action plays. An example in the blend. One thing I noticed though that when I play the animation and deselect the window of Blender reinstancePhysicsMesh is not working.


reinstanceMesh.blend (77.8 KB)

i see this thing one time -> with sensor obj -> collision box.
but i’m not investigate much.

now i retry and 2.65 and it work.

in the blend i not see any sensor obj.
what is ?

This appears to be what I need. I wasn’t using shapekeys before this, but can convert to that and test this. Haven’t really done much python at all before this, so Ill have to study the code, but looks like I can figure it out.

Should be the first object that is selected when you open the .blend file.

You don’t need a shapekey action. You could also do it by scaling a child object. I didn’t expect that just scaling the object would require to update the mesh with reinstancePhysicsMesh, so maybe Monster knows something more about this? Next step will be testing to scale with python (without an action) to see if this is an “action” issue or not.

EDIT: It seems that even with scaling through python using “localScale” the mesh doesn’t always update. Is this normal?


reinstanceMesh2.blend (78.7 KB)

Okay, I figured it out. Only with a shapekey action it is really necessary to update the Mesh with reinstancePhysicsMesh. In every other case updating the Mesh isn’t necessary when colliding with objects with Collision Bounds set to “Triangle Mesh”.

EDIT: However, I might need a lesson on using compound objects because I can’t seem to make it work…


reinstanceMesh2a.blend (79 KB)

i guess , if you choose box as collision , the shape of collision can be different from what you expect.

(not very clear how is calculated… )

anyway not there difference using python (localScale) or action


sensorScale(correct).blend (79.5 KB)

@ MarcoIT:
I see. But the Physics Mesh of a child object (compound) doesn’t seem to update when Collision Bounds are set to “Box”.

@ deranjer:
Maybe replaceMesh suits your needs better. Here’s an example:


Crouch00.blend (80.5 KB)

maybe i not understand well what you mean , but to me seem that work.(i mean just with cube->cube)

the coupound must be selected for both obj (parent and children) otherwise not work.

I’m sorry for my ignorance and thank you for helping me. So I set collision bounds to “box” and selected “compound” for both parent and child. But the action of the child won’t update. Am I still doing something wrong here?


reinstanceMesh2b.blend (80.8 KB)

you say well.

I had used coupund some time ago, and just by chance I did not notice these problems.

to update the collision coumpound, you must reset parent. (this anyway, maybe this is not a bug)

as always, the real bugs are in the UI. (such as dynamic objects that become static if they are children, in the UI…EDIT: or maybe also this bug is children of the “master bug” children static!)
children sensor -> no coupund (and not parent)
body mesh -> coupound

you have to set the parent in run time then, and when you change scale, you should remove parent and Reparent.:spin:


updateCoupound.blend (78.4 KB)

Thanks man. I think this will come in handy.