# Moving vertices along normal axis in BGE

I'm using BGE and I need to move the vertices of a mesh using Python. I know how to change the position of the vertices in real time but the problem is that they move using LOCAL coordinates and I need to move them along NORMAL coordinates.

I found the code below but I don't know what to do with "nor", or maybe this is not the right way, I don't know.

###### get the vertex normal vector
# get controller
controller = GameLogic.getCurrentController()
# get object the controller is attached to
obj = controller.owner
# get the 1st mesh
mesh = obj.meshes
# get the first vertex of the first material
vert  = mesh.getVertex( 0, 0)
# get normal of this vertex
nor = vert.normal


The vertex normals are the interpolated normals of the faces which are perpendicular to the faces. The vertex normals are normalized this means the length of this vector is 1, therefore you might want to scale them before adding the normal vector to the vertex coordinates. Moving the vertices along their normals would create an effect as shown in the this image: import bpy
import GameLogic
###### get the vertex normal vector
# get controller
controller = GameLogic.getCurrentController()
# get object the controller is attached to
obj = controller.owner
# get the 1st mesh
mesh = obj.meshes
for v in range(mesh.getVertexArrayLength(0)):
vert = mesh.getVertex(0, v)
norm = vert.normal * .3
vert.XYZ = (vert.x + norm.x, vert.y + norm.y, vert.z + norm.z )

• how would you go about doing this "scale them before adding the normal vector" bit you speak of ? – user7500 Oct 15 '14 at 2:52
• @red566 Didn't test it but multiplying each x,y,z value by scaling factor e.g. 1.1 in last line could do it (when I get you right). – stacker Oct 15 '14 at 5:41