Page MenuHomeFeedback Tracker

attachTo to weapon proxy with followBoneRotation and offset leads to shifting
New, NormalPublic

Description

When using attachTo with "proxy:\a3\characters_f\proxies\weapon.001" as memPoint and followBoneRotation set to true and an offset, the attached objects shifts up and down relative to the weapon when aiming up and down. Since there is no weapon animation running, the object should look just like a weapon attachment, but it doesn't.

Details

Severity
Minor
Resolution
Open
Reproducibility
Always
Operating System
Windows 11 x64
Category
Scripting
Steps To Reproduce
  • Spawn as an Autorfileman or any other unit with an IR laser
  • Execute the following code:
private _model = getText (configFile >> "CfgWeapons" >> primaryWeapon player >> "model");
private _dummy = createSimpleObject [_model, [0, 0, 0], true];
private _proxyOffset = _dummy selectionPosition ["\a3\data_f\proxies\weapon_slots\SIDE.001", 1];
_proxyOffset = [_proxyOffset#1, _proxyOffset#0 * -1, _proxyOffset#2];
deleteVehicle _dummy;

private _sphere = createSimpleObject ["Sign_Sphere10cm_F", [0, 0, 0]];
_sphere attachTo [player, _proxyOffset, "proxy:\a3\characters_f\proxies\weapon.001", true];
_sphere setObjectScale 0.1;
  • Observe the position of the sphere when aiming towards the horizon
  • Compare with the position of the sphere when aiming to the sky or to the ground

Event Timeline

This comment was removed by Geez.
Geez added a subscriber: Geez.Mar 10 2023, 9:36 AM
dedmen set Ref Ticket to AIII-55593.Mar 16 2023, 10:33 AM

It's because "followBone" attaches the object to the "memory" LOD, which doesn't match the visual LOD:

_w = currentWeapon player;
_cfg = configFile >> "CfgWeapons" >> _w;
_m = getText(_cfg >> "model");
_o = createSimpleObject [_m, [0,0,0]];
_o attachTo [player, [0,0,0], "proxy:\a3\characters_f\proxies\weapon.001", true];
_o setDir 90
onEachFrame {
	_w = primaryWeapon player;
	//update weapon info upon weapon switch
	if (_w != player getVariable ["last_weapon", "?"]) then {
		_cfg = configFile >> "CfgWeapons" >> _w;
		_m = getText(_cfg >> "model");
		//if (_m select [0,1] == "\") then {_m = _m select [1]};
		_o = createSimpleObject [_m, [0,0,0], true];
		_off = _o selectionPosition [getText(_cfg >> "muzzlePos"), "memory"]; 
		_off = _off apply {[_x]};
		deleteVehicle _o;
		player setVariable ["offset", _off];
		player setVariable ["last_weapon", _w];
		player setVariable ["proxy", 
			[
			"proxy:\a3\characters_f\proxies\pistol.001",
			"proxy:\a3\characters_f\proxies\weapon.001",
			"proxy:\a3\characters_f\proxies\launcher.001",
			"proxy:\a3\characters_f\proxies\binoculars.001"
			
			] select (([1, 4, 4096] find getNumber(_cfg >> "type")) + 1)
		
		
		];
	};
	_offset = player getVariable ["offset", []];
	_proxy = player getVariable ["proxy", ""];
	player selectionVectorDirAndUp [_proxy, 1e15] params ["_vy", "_vz"];
	_pos = player selectionPosition [_proxy, 1e15] vectorAdd[0.33,0,0];
	
	_vx = _vy vectorCrossProduct _vz;
	
	_mat = matrixTranspose [_vx, _vy, _vz];
	_pos = _pos vectorAdd flatten(_mat matrixMultiply _offset);
	
	_p1 = player modelToWorldVisualWorld _pos;
	_p2 = _p1 vectorAdd (player vectorModelToWorldVisual (_vy vectorMultiply 1000));
	drawLine3D [ASLtoAGL _p1, ASLtoAGL _p2, [1,0,0,1]];
}