Category | Scripting |
Created | 13.07.2020 12:11 |
Tom Stirnkorb (CR4NKH) | 13.07.2020 12:11 |
---|---|
Hello, 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. Any ideas? |
Th. Birrer (Ralf08) | 14.07.2020 21:04 |
---|---|
getTerrainHeightAtWorldPos 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. Regards Thomas |
Gtx | Andy (GtX_Andy) | 06.08.2020 12:36 |
---|---|
Hey, You could do this using 'raycastClosest' function. https://gdn.giants-software.com/documentation_scripting_fs19.php?version=engine&category=9&function=118 Example Use --------------------- function MyScript:getDistance() 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 end function MyScript:raycastCallback(hitObjectId, x, y, z, distance) if hitObjectId == g_currentMission.terrainRootNode then self.hitTerrain = true self.distance = distance end return false end |
Note: Log in to post. Create a new account here.