Jump to content
doubleblind

[Help Requested] Bar Gate Spawning Issue

Recommended Posts

Hey everybody,

 

I'm getting pretty close to finished on improved versions of the BIS_fnc_objectsGrabber/BIS_fnc_objectsMapper functions but I'm running into one particular snag that I can't figure out. The bar gate object, "Land_BarGate_F", isn't spawning in the correct position when spawned at any azimuth other than due north. Here's a picture of it spawning at 0 degrees:

VSm9VcM.jpg

 

and here's a picture of it spawning at a different angle:

nZpISiE.jpg

 

As you can see, at a different angle it spawns out of place. Here are the functions I'm using to spawn compositions (apologies in advance for the code dump):

 

Example config entry:

objects[] =
				{
					{"Land_BarGate_F",{3.42554,0.0320976,0.00323486},0.402328},
					{"Land_CncBarrier_F",{3.56418,-1.92152,0},-90.1721},
					{"Land_CncBarrier_F",{3.54114,1.99699,9.53674e-006},-90.1721},
					{"Land_CncBarrier_F",{-3.8572,-1.62853,2.86102e-005},-90.1721},
					{"Land_CncBarrier_F",{-3.87824,1.72854,2.86102e-005},-90.1721},
					{"RoadCone_L_F",{3.56628,-3.4401,0.00211143},0.065033},
					{"RoadCone_L_F",{3.54395,3.52312,0.00223351},0.0621948},
					{"RoadCone_L_F",{-3.86675,-3.20776,0.00213242},0.0647278},
					{"Land_PortableLight_double_F",{-4.82907,1.52948,5.91278e-005},-20.4304},
					{"RoadCone_L_F",{-3.88475,3.22092,0.00215912},0.0650024},
					{"Land_PortableLight_double_F",{4.96732,-4.48994,0},-195.793},
					{"I_MRAP_03_hmg_F",{-6.80197,-4.82961,0.0112801},16.556}
				};

Spawn function:

_anchor = _this select 0;
_path = _this select 1;

_location = markerPos _anchor;
_dir = markerDir _anchor;

_objects = getArray (_path >> "objects");
_units = getArray (_path >> "units");

{
	_type = _x select 0;
	_v = _x select 1;
	_azi = _x select 2;
	
	_v1 = [_v,_dir] call CH_fnc_rotateVector;
	_pos = [_location,_v1] call CH_fnc_vectorToPos;
	_object = createVehicle [_type,_pos,[],0,"CAN_COLLIDE"];
	_object setDir (_azi + _dir);
} forEach _objects;

CH_fnc_rotateVector:

_vector = _this select 0;
_theta = -(_this select 1);

_x1 = _vector select 0;
_y1 = _vector select 1;

_x2 = (_x1 * (cos _theta)) - (_y1 * (sin _theta));
_y2 = (_x1 * (sin _theta)) + (_y1 * (cos _theta));

_newVector = [_x2,_y2,_vector select 2];
_newVector 

CH_fnc_vectorToPos:

_anchor = _this select 0;
_vector = _this select 1;

_x1 = _anchor select 0;
_y1 = _anchor select 1;
_dx = _vector select 0;
_dy = _vector select 1;

_x2 = _x1 + _dx;
_y2 = _y1 + _dy;

_newPos = [_x2,_y2];
_newPos 

Part of me thinks that it's an issue with the engine's interpreted "center location" of the gate itself, but I'm not prepared to give up so easily. Does anybody have any thoughts on how to solve this?

Share this post


Link to post
Share on other sites

There's a road block script Here that uses the bar gate, why not see how I34dKarma does it ?

Share this post


Link to post
Share on other sites
20 minutes ago, richie said:

There's a road block script Here that uses the bar gate, why not see how I34dKarma does it ?

I took a look at it, l34dKarma's demo mission seems to be having similar problems to what I'm seeing:

ghnRcu5.jpg

Makes me think that an update between l34dKarma's publishing and now broke the bar gate placement. Thanks for the pointer though, it's good to know that it's not necessarily my math that's the problem.

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

×