# Control for adjusting height not always working properly

Hi, I’ve created a Control for terrain that should gradually set the heightmap of a terrain to a specified height on a position defined by Vector3f loc.

It basically works most of the times, but I also get weird behaviour, like many spikes rising from the floor…

I suspect this has something to do with the interpolation of the loc.

(I’ve also tried with Terrain.setHeight(), but it skip to the final result)

This is the code of the control:

[java]public class RullalControl extends AbstractControl{

``````Vector3f loc;
float tpf=0;
List&lt;Vector2f&gt; locs = new ArrayList&lt;Vector2f&gt;();
List&lt;Float&gt; heights = new ArrayList&lt;Float&gt;();
float height=10;

this.loc=loc;
this.terrain=terrain;
//start = System.currentTimeMillis();
}

@Override
protected void controlUpdate(float tpf) {

//long tTime=System.currentTimeMillis()-start;

// offset it by radius because in the loop we iterate through 2 radii

float xStepAmount = terrain.getLocalScale().x;
float zStepAmount = terrain.getLocalScale().z;

float locX = loc.x + (x * xStepAmount);
float locZ = loc.z + (z * zStepAmount);

{
// see if it is in the radius of the tool
float hLocal=terrain.getHeight(new Vector2f(locX, locZ));
if ((hLocal-height)&gt;=1){
}
else if((hLocal-height)&lt;0){
}
//float h = calculateHeightRulla(radius, height, locX - loc.x, locZ - loc.z);
}
}
}
//System.out.println("Modified "+locs.size()+" points, took: " + (System.currentTimeMillis() - start)+" ms");
heights.clear();
locs.clear();
terrain.updateModelBound();
this.tpf+=tpf;
if (this.tpf&gt;5){
spatial.removeControl(this);
}
}
Vector2f point = new Vector2f(x, y);
// return true if the distance is less than equal to the radius
}
@Override
protected void controlRender(RenderManager rm, ViewPort vp) {
//throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
``````

}
[/java]