Jump to content
th3gingergamer

Props lose collisions after being moved with setPos

Recommended Posts

So I created a tiny script where a user could lower bollards with an addACtion on one of them. The script detects bollards within a certain distance and then lowers them all simultaneously. After about 10 seconds the bollards begin raising back up and return to their original position. Once the bollards raise back up they seem to lose all collisions with vehicles. All the bollards have simulation disabled and damage disabled via the init code on them. The bollard with the addAction also just seems to lose the addAction if you tap it with a vehicle, even before it's been moved.

Share this post


Link to post
Share on other sites

You're going to need to post some code, otherwise all anyone can do is make assumptions about what you're doing behind it all.

  • Like 1

Share this post


Link to post
Share on other sites

Sorry I'm really ill and dozy right now.

_type =  "Land_Bollard_01_F";
_playerCalling = vehicle player;
_bollards = (getPos (_this select 0)) nearObjects [_type, 15];
_height = 0;
for [{_i=0}, {_i<50}, {_i=_i+1}] do
{
    {_x setPos[getpos(_x) select 0, getpos (_x) select 1, _height - 0.02];} forEach _bollards;
	sleep 0.05;
	_height = _height - 0.02;
};
hintSilent "Bollards Opened";
sleep 10;
for [{_i=0}, {_i<50}, {_i=_i+1}] do
{
    {_x setPos[getpos(_x) select 0, getpos (_x) select 1, _height + 0.02];} forEach _bollards;
	sleep 0.05;
	_height = _height + 0.02;
};
hintSilent "Bollards Closed";

Here's the full code

  • Like 1

Share this post


Link to post
Share on other sites

Ok, so here is what I did to try and replicate what you're describing. In the editor, I placed a manned Hunter, and infront of that I placed 3 bollards of the type you're using, spaced 2 meters apart. On all bollards I unchecked the boxes "Enable Simulation" and "Enable Damage", so that they all have their simulation and damage disabled. In the init field of the middle bollard I placed the code:

nul = [this] execVM "addAction.sqf";

 

In the mission's folder, I made a file called addAction.sqf and in that is where I added the action to the bollard (I'm making an assumption that you've done the same, but you haven't specified) without any conditions or any other inputs, just straight up added the action:

params ["_obj"];

_obj addAction ["Lower/Raise",{
	params ["_target", "_caller", "_actionId", "_arguments"];
	nul = [_target] execVM "bollards.sqf";
}];

 

I made another file, called bollards.sqf, and added your code in as-is:

_type =  "Land_Bollard_01_F";
_playerCalling = vehicle player;
_bollards = (getPos (_this select 0)) nearObjects [_type, 15];
_height = 0;
for [{_i=0}, {_i<50}, {_i=_i+1}] do
{
    {_x setPos[getpos(_x) select 0, getpos (_x) select 1, _height - 0.02];} forEach _bollards;
	sleep 0.05;
	_height = _height - 0.02;
};
hintSilent "Bollards Opened";
sleep 10;
for [{_i=0}, {_i<50}, {_i=_i+1}] do
{
    {_x setPos[getpos(_x) select 0, getpos (_x) select 1, _height + 0.02];} forEach _bollards;
	sleep 0.05;
	_height = _height + 0.02;
};
hintSilent "Bollards Closed";

 

It worked. At no point did the action disappear (except for when I wasn't looking at the middle bollard). So I'm not sure why yours wouldn't be working. So if you're still having problems feel free to use what's above and go and edit/change whatever you need to suit. This was just a quick thrown together example to show it working.

  • Like 1

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

×