Heightmap to world location

Hello I’m trying to create a map generator. I already have a good height map but now I want to place items on the map. In order to do this I’m generating 2 random coordinates and look up the height in the height map. I think this should work however the height map uses coordinates between 1 and 0 were as the rest of the game uses number in the range of hundreds. How do I translate between the two?

This is too vague: is your height map being used to generate a terrain? If so, the code that generates the terrain should be examined in order to know how it translates map coordinates and the look up values to world space. You should post this code, or a link to it.

Anyway, the basic transformations are easy: you must defined the desired world sizes of your map in the world X, and Z axis. Supposing that your map should measure 1000 in the X and Z directions, and that the max height is 500, you could define the map scale in the appropriate fields in the script below, and get the height at some specific world position with the function GetHeight:

var mapOrg: Vector3 = Vector3(-100, 0, -100);
var mapSizeX: float = 1000;
var mapSizeZ: float = 1000;
var mapHeight: float = 500;

function GetHeight(worldX: float, worldZ: float): float {
  var normX: float = (worldX-mapOrg.x)/mapSizeX;
  var normZ: float = (worldZ-mapOrg.z)/mapSizeZ;
  var normY: float = (get height map value at point x,z)
  return (normY*mapHeight)+mapOrg.y;
}

My code :

	function Start () {

	    var xRes = terrain.terrainData.heightmapWidth;
	    var yRes = terrain.terrainData.heightmapHeight;
	    var heights = terrain.terrainData.GetHeights(0, 0, xRes, yRes);
	   

	
	var fxRes : float=xRes;
	var fyRes : float =yRes;
	//generate heightmap.