Jump to content
Sign in to follow this  
wok

Problem with attachTo & setVectorDirAndUp

Recommended Posts

I am trying to attach a helmet onto a table, but I dont like that the visor part points down when I do this, so I was trying to use setVectorDirAndUp to rotate the helmet. For example:

_table = "Land_CampingTable_F" createVehicle position player;
_helmet = "groundWeaponHolder" createVehicle position _table;
_helmet addWeaponCargo ["H_PilotHelmetHeli_B", 1];
_helmet setVectorDirAndUp [[1,0,0],[0,-1,0]];

That works for rotating the helmet, but when I add this:

_helmet attachTo [_table, [0,-0.5,1.15]];

The helmets has always the same position with the visor pointing down. Am I doing something wrong? Or is there a limitation with certain objects, because if I attach it to the player then the helmet keeps the rotation I set with setVectorDirAndUp.

Share this post


Link to post
Share on other sites

Call the attachTo first, then the setVectorDirAndUp. Also, remember that after using attachTo, rotations are relative to the object that it has been attached to.

Share this post


Link to post
Share on other sites
Call the attachTo first, then the setVectorDirAndUp. Also, remember that after using attachTo, rotations are relative to the object that it has been attached to.

I am actually doing that, I just separated the attachTo on the sample code to show that the rotation was working without it. This is my test code:

_table = "Land_CampingTable_F" createVehicle position player;
_helmet = "groundWeaponHolder" createVehicle position _table;
_helmet addWeaponCargo ["H_PilotHelmetHeli_B", 1];
_helmet attachTo [_table, [0,-0.5,1.15]];
_helmet setVectorDirAndUp [[1,0,0],[0,-1,0]];

I tried different numbers on setVectorDirAndUp, but the rotation of the helmet never changes once attached.

EDIT: The problem must be the table, I found a workaround, I placed a pointer (helper) and attached it to the table, then spawned the helmet on the pointer position and rotated it. That keeps the helmet rotation, now just need to figure out the right position where to attach the pointer so the helmet looks like its resting on the table.

EDIT2: The pointer method didn't work because I wasn't able to set the right Z position, so I just used enableSimulation false + setPos, I don't know why I didn't use that from the beginning, I've used it before.

Edited by wok

Share this post


Link to post
Share on other sites

alternate method:

_table = "Land_CampingTable_F" createVehicle getPos player;
_wh = createVehicle ["groundWeaponHolder", getPos _table, [], 0, "can_collide"];
_wh addWeaponCargo ["H_PilotHelmetHeli_B", 1];
_wh setPos (_table modelToWorld [0,-0.5,-0.87]);
[_wh, 90, 0] call BIS_fnc_setPitchBank;

updated

Edited by Mattar_Tharkari

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  

×