Game Object: reinstancePhysicsMesh

reinstancePhysicsMesh(object, mesh)
  • Uses the new mesh to update the physics of the game object.

Return type:  boolean

  • Physics updated: True
  • Physics not updated: False

object:

  • Type:  string or KX_GameObject
mesh:
  • Type:  string or KX_MeshProxy
Note:
  • Only works with Collision Bounds Type: Triangle Mesh.
     
  • Use reinstancePhysicsMesh() to reinstance the original mesh of the game object.
Sample Code

################### update the physics of the game object
  

# import bge
import bge

# get controller
cont = bge.logic.getCurrentController()

# get current scene
scene = bge.logic.getCurrentScene()

# get a list of the objects
objList = scene.objects

# get object named Suzanne
suz =objList["Suzanne"]

# get a list of the meshes on Suzanne
meshList = suz.meshes

# get the first mesh
mesh = meshList[0]

# get object that controller is attached to
# obj Collision Bounds: Triangle Mesh

obj = cont.owner

# update obj physics mesh to suz physics mesh
obj.reinstancePhysicsMesh(suz, mesh)