Jump to content
Sign in to follow this  
Sgt DeWolf

Movable Object Through BIS_fnc_relPos

Recommended Posts

I'm trying to set up a target that can by moved with a scroll wheel  command and BIS_fnc_relPos.

 

Player initialization box: player addAction ["Move 100m Out","[target1,100,0] call BIS_fnc_relPos"];player addAction ["Move 100m In","[target1,100,180] call BIS_fnc_relPos"];

Sign I want to moved is named: target1

 

Playing as a single player scenario.

Commands show up on the scroll wheel but target does not move. I've wasted hours trying to get this to work. I'm stumped.

 

 

 

 

Share this post


Link to post
Share on other sites

You need to actually move the object:

player addAction ["Move 100m Out","target1 setPos ([target1,100,0] call BIS_fnc_relPos)"];

player addAction ["Move 100m In","target1 setPos ([target1,100,180] call BIS_fnc_relPos)"];

All your actions did was get the position 100 meters away. Btw with this code, the targets will only move N or S

  • Like 1

Share this post


Link to post
Share on other sites

In addition to DreadedEntity's answer, we can make this even a bit more compass-independent:

_fnc_setDistance = {
    params ["_target", "_caller", "_id", "_params"];
    _object = _params select 0;
    _distance = _object getVariable "distance";
    //_distanceDiff = _params select 1;
    _distance = _distance + (_params select 1);
    _object attachTo [player, [0, _distance, 0]];
    _object setVariable ["distance", _distance];
};

_object = createVehicle ["Sign_Sphere100cm_F", getPosATL player, [], 0, "CAN_COLLIDE"];
_object setVariable ["distance", 100];
_object attachTo [player, [0, 100, 0]];

player addAction ["Move 100m Out", _fnc_setDistance, [_object, 100]];
player addAction ["Move 100m In", _fnc_setDistance, [_object, -100]];
player addAction ["Release", {detach (_this select 3);}, _object];

Share this post


Link to post
Share on other sites

Another approach, which will also work on hilly terrain (because why not :D):

_fnc_setDistance = {
    _params = _this select 3;
    _object = _params select 0;
    _object setVariable ["distance", (_object getVariable "distance") + (_params select 1)];
};

_object = createVehicle ["Sign_Sphere100cm_F", getPosATL player, [], 0, "CAN_COLLIDE"];
_object setVariable ["distance", 100];

_handle = _object spawn {
    while {true} do {
        _newPos = player modelToWorld [0, _this getVariable "distance", 0];
        _newPos set [2, 0.5];
        _this setPosATL _newPos;
    };
};

player addAction ["Move 100m Out", _fnc_setDistance, [_object, 100]];
player addAction ["Move 100m In", _fnc_setDistance, [_object, -100]];
player addAction ["Release", {terminate (_this select 3);}, _handle];

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  

×