How to change object physics type when game is running

Hi, I’ve got a problem, I want to check some things in bge, I’ve prepared object in one layer(for example object name is “TEST”), object physics type is “STATIC”, I want to add this object to another layer, and change his physics type to “RIGID_BODY”, so it will fall down when added. When start a game, scripts run without errors, physics type of added object is changed, but object is behaving like “STATIC”, it’s hanging in one place and that’s all. Is it possible to change physics type in bge when game is running or I should use different method of changing physics type ? Thx in advance for any help. Below is sample code that I’m using to change object physics type.

scnScene = bge.logic.getCurrentScene()
own = arrSensors[i].owner # arrSensors[i] sets earlier
obj = scnScene.addObject("TEST",own,150)
data.objects[].game.physics_type = 'RIGID_BODY'
data.objects[].game.damping = 0.600
data.objects[].game.rotation_damping = 0.100

You’re using bpy, which is not for use in the game engine. Hence, the code doesn’t change the scene until after runtime

I was trying to do this a while back also. As far as I know (somebody correct me if I’m wrong), there is no way to change the physics type in-game. I ended up just having a duplicate mesh with a different physics type and swapping the meshes (using Edit Object>End Object and Edit Object>Add Object actuators). This may not work in all situations though.

Ok, thx guys, I will just replace object with another object with different physic type

If you set the collision bounds to triangle mesh you can use edit object->replace mesh, and it can inherent the physics of the new mesh. Then you won’t have to end and add objects.