Game Object: replaceMesh

replaceMesh(meshName, displayMesh, physicsMesh)
  • Replaces the mesh of the object with a new mesh.

meshName:

  • name of the replacement mesh
  • Type:  string
displayMesh:
  • Type:  boolean
  • Show the replacement mesh: 1 or True
  • Don't show the replacement mesh: 0 or False
physicsMesh:
  • Type:  boolean
  • Update physics with new mesh: 1 or True
  • Don't update physics: 0 or False
Note:
  • Only works with Collision Bounds Type: Triangle Mesh.
Sample Code

################### replace the mesh of the object with a new mesh
  
# import bge
import bge

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

# get object that controller is attached to
obj = cont.owner

# name of replacement mesh
# I have a mesh on another game object named Dent

mesh = "Dent"

# display the replacement mesh
displayMesh = True

# update physics with new mesh
physicsMesh = True

# replace mesh, show it, update physics
obj.replaceMesh(mesh, displayMesh, physicsMesh)