Community Forum

Finding object's world position?

Forum Overview >> Farming Simulator 19

CategoryFarming Simulator 19
Created05.06.2019 13:07


M Oliver (Unknown) 05.06.2019 13:07
I have some placeholder objects several transform levels deep. Their translations are, of course, relative to their parent group.

I need to determine their absolute translations for the default items XML file. Is there a simple way to do this?

Bilbo Beutlin (BBeutlin) 05.06.2019 15:13
Create a transform group, place it with Ctrl-B exactly where your object has its origin (gizmo). Perhaps make the object invisible (temporarily) for better placement.

Or write a simple GE-script which calculates local-to-world position of a TG.

M Oliver (Unknown) 05.06.2019 17:45
"Or write a simple GE-script which calculates local-to-world position of a TG."

That sounds like exactly what I need to do, but I have no idea how to do that :-(

Bilbo Beutlin (BBeutlin) 05.06.2019 20:01
Select menu Script -> Create new script
Enter (copy'n'paste)
---------- code ----------
local node = getSelection(0)
if node > 0 then
local x,y,z = getWorldTranslation(node)
print(string.format("x=%d y=%d z=%d",x,y,z))
end
--------------------------
For usage activate console window, select a TG, run the script

If you need it more precise, replace in string.format() the "%d" eg. for two digits with "%.2f".

M Oliver (Unknown) 08.06.2019 22:21
Thanks very much for that, it works a treat!




Note: Log in to post. Create a new account here.