I'm interested in this position plus the yInterkarma wrote: ↑Sat May 05, 2018 10:36 pmHere's how the location transform is calculated currently.TheLacus wrote: ↑Sat May 05, 2018 5:19 pm The position of a location calculated at line 1048 of StreamingWorld is not the one assigned to the transform. Not sure how location layout works, is scene position accessible somewhere? I can make the same calculations again but i think there is an easier way to get from location instance to terrain position. If not, may be useful to store it in a field?
The location is a separate gameobject not parented to the terrain, just the transforms are aligned so the location is in right spot. Everything in location is parented to the location parent.Code: Select all
[1049] float height = terrainInstance.SampleHeight(pos + terrainArray[terrain].terrainObject.transform.position); ... [1056] locationObject.transform.position = terrainArray[terrain].terrainObject.transform.position + new Vector3(0, height, 0);
What would be more useful for your mod, the location transform or the terrain transform?
Code: Select all
float scale = terrainInstance.terrainData.heightmapScale.x;
float xSamplePos = dfUnity.TerrainSampler.HeightmapDimension * 0.55f;
float ySamplePos = dfUnity.TerrainSampler.HeightmapDimension * 0.55f;
Vector3 pos = new Vector3(xSamplePos * scale, 0, ySamplePos * scale);
Code: Select all
locationObject.transform.position = terrainArray[terrain].terrainObject.transform.position + new Vector3(0, height, 0);
Now that i read the code again, i see there is also LocationRect but in Daggerfall world units so providing access to CityNavigation.WorldToScenePosition() from UpdateLocation() may also be an alternative.