Jump to content
Sign in to follow this  
fail2ban

Replace building - finding the correct position

Recommended Posts

Hi there,

it's my first post, so first of all "Hello" to everyone.

I am trying to replace buildings on a Lingor map. Actually I need to replace the Land_MBG_Police_Station by itself, because in my version I cannot open the doors anymore (if I spawn one by using createVehicle instead the building performs like intended).

Therefor I am trying to retrieve the objects position, hide the original object and put a new object on the exact same place. Hiding the object is not a problem, but getting the correct position for the new one.

f2b_test={	
private ["_test","_testPos","_testPosASL"];
_test = nearestObject [player, "Land_MBG_Police_Station"]; 
_test call DT_fnc_log;
_testPos = getPos _test;
_testPos call DT_fnc_log;
_testPosASL = getPosASL _test;
_testPos = ASLToATL _testPosASL;
_testPos call DT_fnc_log;	
_testPos = getPosATL _test;
_testPos call DT_fnc_log;
_testPos = visiblePosition _test;
_testPos call DT_fnc_log;
};

[] spawn f2b_test;

The result of the function above is the following

14:07:40 - 28b26400# 267252: mbg_police_station.p3d // _test - object
14:07:40 - [6853.38,4518.18,-0.239998] // getPos
14:07:40 - [6855.48,4518.35,0] // getPosASL to ATL
14:07:40 - [6855.48,4518.35,0] // getPosATL
14:07:40 - [6853.38,4518.18,-0.239998] // visiblePosition

As you can see X and Y coords of the returned position array are different for the getPos / visiblePosition compared to the ASL / ATL functions. This is the first thing I do not understand. How can it be different?

But now matter what, all of the methods above won't let me spawn the same building in the same position if I do something like

f2b_test={
private ["_test","_testPos","_testDir"];
_test = nearestObject [player, "Land_MBG_Police_Station"]; 
_testPos = getPos _test;
_testDir = getDir _test;

_test hideObject true;

sleep 2; // see if it is gone

f2b_1 = createVehicle ["Land_MBG_Police_Station", _testPos, [], 0, "CAN_COLLIDE"];
f2b_1 setDir _testDir;
f2b_1 setPos _testPos;
};

[] spawn f2b_test;

I have tried it with all methods mentioned above, but the newly spawned building has always have a slight offset to the original position. Is there anything I am missing. Does an object have an offset relative to its map coords somewhere I am not aware of and that I need to add or substract?

Thx very much in advance

Edited by fail2ban

Share this post


Link to post
Share on other sites

As for the reasons, I don't know exactly what's causing this but using modelToWorld from the original object and then applying setPosATL to the result with 0 z-coordinate seems to do it for me.

Share this post


Link to post
Share on other sites
As for the reasons, I don't know exactly what's causing this but using modelToWorld from the original object and then applying setPosATL to the result with 0 z-coordinate seems to do it for me.

Thank you, but using modelToWorld brings up this

[6855.48,4518.35,1.36]

which is X- and Y-wise the same as the ASL / ATL functions

Guess I have used it the way you meant

f2b_2 = nearestObject [player, "Land_MBG_Police_Station"];  
_test = f2b_2 modelToWorld [0,0,0];  
_test call DT_fnc_log;

Or did I do it wrong?

Share this post


Link to post
Share on other sites

Yes, that's how I tested it. For me this was the exact correct position (along x & y) when I respawned the building (the control tower on Utes). I only tested vs the basic getPos/setPos which indeed did place the building incorrectly, so I presumed this might work (as you hadn't tried that yet). But now as I tested further, apparently getPosATL/setPosATL does work for that building (setting it to the exact correct spot), so there's that. I don't have Lingor island myself to test on that particular building at this time though, I'm afraid. There's also visiblePositionASL that you could try I guess.

Edited by geqqo
visiblePositionASL note

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×