setMass method to disable collisions

This commit is contained in:
commy2 2019-03-24 09:26:00 +01:00
parent cea1599112
commit 6ac2906aba
7 changed files with 37 additions and 36 deletions

View File

@ -83,6 +83,11 @@
_vehicle engineOn false;
}] call CBA_fnc_addEventHandler;
[QGVAR(setMass), {
params ["_object", "_mass"];
_object setMass _mass;
}] call CBA_fnc_addEventHandler;
//Add a fix for BIS's zeus remoteControl module not reseting variables on DC when RC a unit
//This variable is used for isPlayer checks
if (isServer) then {

View File

@ -1,6 +1,6 @@
#include "script_component.hpp"
/*
* Author: commy2, Jonpas
* Author: commy2
* PFH for Carry Object
*
* Arguments:
@ -24,7 +24,7 @@
#endif
params ["_args", "_idPFH"];
_args params ["_unit","_target", "_startTime"];
_args params ["_unit", "_target", "_startTime"];
if !(_unit getVariable [QGVAR(isCarrying), false]) exitWith {
TRACE_2("carry false",_unit,_target);
@ -35,37 +35,10 @@ if !(_unit getVariable [QGVAR(isCarrying), false]) exitWith {
if (!alive _target || {_unit distance _target > 10}) then {
TRACE_2("dead/distance",_unit,_target);
if ((_unit distance _target > 10) && {(CBA_missionTime - _startTime) < 1}) exitWith {
//attachTo seems to have some kind of network delay and target can return an odd position durring the first few frames,
//attachTo seems to have some kind of network delay and target can return an odd position during the first few frames,
//so wait a full second to exit if out of range (this is critical as we would otherwise detach and set it's pos to weird pos)
TRACE_3("ignoring bad distance at start",_unit distance _target,_startTime,CBA_missionTime);
};
[_unit, _target] call FUNC(dropObject_carry);
[_idPFH] call CBA_fnc_removePerFrameHandler;
};
// Disable collision with nearby players
private _disabledCollisionObjects = _target getVariable [QGVAR(disabledCollisionObjects), []];
TRACE_1("Disable collision objects",_disabledCollisionObjects);
private _nearUnits = _target nearObjects ["CAManBase", DISABLE_COLLISION_DISTANCE];
{
if !(_x in _disabledCollisionObjects) then {
TRACE_2("Adding disable collision object",_x,typeOf _x);
_target disableCollisionWith _x;
_disabledCollisionObjects pushBack _x;
};
false
} count _nearUnits;
_disabledCollisionObjects = _disabledCollisionObjects select {
if (_x in _nearUnits) then {
true
} else {
TRACE_2("Removing disable collision object",_x,typeOf _x);
_target enableCollisionWith _x;
false
};
};
_target setVariable [QGVAR(disabledCollisionObjects), _disabledCollisionObjects];

View File

@ -76,3 +76,10 @@ if (_unit getVariable ["ACE_isUnconscious", false]) then {
if (_target getVariable [QGVAR(isUAV), false]) then {
createVehicleCrew _target;
};
// reset mass
private _mass = _target getVariable [QGVAR(originalMass), 0];
if (_mass != 0) then {
[QEGVAR(setMass), [_target, _mass], _target] call CBA_fnc_targetEvent;
};

View File

@ -77,7 +77,9 @@ if (_target getVariable [QGVAR(isUAV), false]) then {
createVehicleCrew _target;
};
// Reenable collision with nearby objects
{
_target enableCollisionWith _x;
} forEach (_target getVariable [QGVAR(disabledCollisionObjects), []]);
// reset mass
private _mass = _target getVariable [QGVAR(originalMass), 0];
if (_mass != 0) then {
[QEGVAR(setMass), [_target, _mass], _target] call CBA_fnc_targetEvent;
};

View File

@ -73,3 +73,11 @@ _unit setVariable [QGVAR(isCarrying), true, true];
_unit setVariable [QGVAR(carriedObject), _target, true];
[FUNC(startCarryPFH), 0.2, [_unit, _target, _timer]] call CBA_fnc_addPerFrameHandler;
// disable collisions by setting the physx mass to almost zero
private _mass = getMass _target;
if (_mass > 1) then {
_target setVariable [QGVAR(originalMass), _mass, true];
[QEGVAR(setMass), [_target, 1e-12], _target] call CBA_fnc_targetEvent;
};

View File

@ -61,3 +61,11 @@ if (_target isKindOf "CAManBase") then {
_unit setVariable [QGVAR(isDragging), true, true];
[FUNC(startDragPFH), 0.2, [_unit, _target, CBA_missionTime + 5]] call CBA_fnc_addPerFrameHandler;
// disable collisions by setting the physx mass to almost zero
private _mass = getMass _target;
if (_mass > 1) then {
_target setVariable [QGVAR(originalMass), _mass, true];
[QEGVAR(setMass), [_target, 1e-12], _target] call CBA_fnc_targetEvent;
};

View File

@ -19,5 +19,3 @@
#define DRAG_ANIMATIONS ["amovpercmstpslowwrfldnon_acinpknlmwlkslowwrfldb_2", "amovpercmstpsraswpstdnon_acinpknlmwlksnonwpstdb_2", "amovpercmstpsnonwnondnon_acinpknlmwlksnonwnondb_2", "acinpknlmstpsraswrfldnon", "acinpknlmstpsnonwpstdnon", "acinpknlmstpsnonwnondnon", "acinpknlmwlksraswrfldb", "acinpknlmwlksnonwnondb"]
#define CARRY_ANIMATIONS ["acinpercmstpsnonwnondnon", "acinpknlmstpsnonwnondnon_acinpercmrunsnonwnondnon"]
#define DISABLE_COLLISION_DISTANCE 5