# Moving vertices relative to center of mesh

I am trying to create a procedural planet generator which I can use within my space game that I am working on. So far I have been able to generate a cube and then turn it into a sphere using magical equations.

I’m now trying to apply a height map to the sphere (cube), however I am coming across problems which I just can’t find a solution for. As I apply the height map to the sphere modifying the y value of each vertex it doesn’t move upwards relative to the center of the sphere but rather the relative to the world. This causes the mesh to move all vertices upwards relative to the world and looks like this:

As you can see the vertices are moving relative to the world instead of the object which is not what I want. So my question is how I would make the vertices move upwards from the center?

Any suggestions on how I would solve this would be really appreciated, thanks!

(The effect I’m trying to achieve is just making the ground of the sphere bumpy)

Get the vertex and sphere center in model coordinates. Then for each vertex calculate direction from the center

``````Vector3 dir = Vector3.normalize(vertexPos - centerPos);
``````

Then multiply you height map value by dir.