I have created a plane and I need to set the Physics Type of the object to NAVIGATION_MESH. I cant figure out, how I should do that. Below is the python script for generating this mesh and setting physics type but unfortunately its not working.

import bpy, mathutils

def create_custom_mesh(objname):
  # Define arrays for holding data 
  myvertex = []
  myfaces = []
  zcord = 11.83068 # Constant Z Coordinate

  # vertex 0
  mypoint = [(-4.64863, -4.80997, zcord)]
  # vertex 1
  mypoint = [(-4.02263, -4.80997, zcord)]
  # vertex 2
  mypoint = [(-4.64863, -4.18397, zcord)]
  # vertex 3
  mypoint = [(-4.02263, -4.18397, zcord)]

  myface = [(0, 1, 3, 2)]
  # Create mesh data      
  mymesh = bpy.data.meshes.new(objname)
  # Create object
  myobject = bpy.data.objects.new(objname, mymesh)

  # Link object to scene
  # Generate mesh data
  mymesh.from_pydata(myvertex, [], myfaces)
  # Calculate the edges
  return myobject

bpy.data.objects['route_plane'].select = True
bpy.data.objects['route_plane'].game.physics_type == 'NAVIGATION_MESH'

What am I making wrong here, cause the object 'route_plane' gets created and being placed at the correct location in the scene but physics type is never set. I need to set the "Navigation Mesh" physics type on an existing object, like 'route_plane' (as in the above code). I can not generate the navigation mesh via the relevant button in the scene properties using GUI.

Please help me, thanks in advance !


1 Answer 1


The enum for a navigation mesh is 'NAVMESH' not 'NAVIGATION_MESH'. The python console is your friend here.

>>> C.object.game.physics_type = 'SOMETHING_WRONG'
Traceback (most recent call last):
  File "<blender_console>", line 1, in <module>
TypeError: bpy_struct: item.attr = val: enum "SOMETHING_WRONG" not found in ('NO_COLLISION', 'STATIC', 'DYNAMIC', 'RIGID_BODY', 'SOFT_BODY', 'OCCLUDER', 'SENSOR', 'NAVMESH', 'CHARACTER')

You weren't getting an error because you had the double equals == which is a boolean test

game.physics_type == 'NAVIGATION_MESH'

Which will equate to False, more commonly I make the mistake of one equals, if (x=y) lol.

  • $\begingroup$ I dont know why I make such stupid mistakes (double equals '=='), but anyway that fixed my problem, with the enum. I owe you a drink man !! Thanks a lot. $\endgroup$
    – sosoup
    Sep 24, 2015 at 12:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .