|Tom Stirnkorb (CR4NKH)||13.07.2020 12:11|
I would like to calculate the distance of an implement to the ground.
I tried to use localToLocal() to get the height relative to the vehicle the implement is attached to, but that isn't quite satisfying for my needs.
Is there a way to get the distance of an object to the ground?
Or just to get the terrain height at a specific position would already help a lot.
|Th. Birrer (Ralf08)||14.07.2020 21:04|
Years ago, when I developed my frontloaderdisplay for FS17, I started also with this function, but I was not happy with it, it was only running properly over "terrain" (the one you can change in FS19 with the landscaping tool), as example on the roads or on concrete squares it is possible, that the terrain is much deeper, so that you will calculate not the true height over ground (ground is not equal to terrain!). On the FS17 Goldcrest Valley map, there is a hole under the concrete directly by the farm equipment dealer. It took me a while until I figured out, that there is not a fault in my script, there is a not visible "flub" in the giants map.
|Gtx | Andy (GtX_Andy)||06.08.2020 12:36|
You could do this using 'raycastClosest' function.
self.distance = 0
self.hitTerrain = false
local x, y, z = getWorldTranslation(self.implementNode)
raycastClosest(x, y, z, 0, -1, 0, "raycastCallback", 10, self, 59)
return self.distance, self.hitTerrain
function MyScript:raycastCallback(hitObjectId, x, y, z, distance)
if hitObjectId == g_currentMission.terrainRootNode then
self.hitTerrain = true
self.distance = distance
Note: Log in to post. Create a new account here.