Jump to content
Alert23

Attachto player weapon

Recommended Posts

Hi all,

 

i want to attach a lightpoint the weapon of the player and make it move with the gun movement but unfortunatly it dosent move the with gun movement.

 

_flashlight = "Reflector_Cone_01_Long_white_F" createVehicle [0,0,0];  
_flashlight attachTo [player, [0.1,0,0], "proxy:\a3\characters_f\proxies\pistol.001"]; 
 
addMissionEventHandler ["EachFrame", {  
_flashlight setVectorDirAndUp [  
(player selectionPosition "nabojnicestart") vectorFromTo (player selectionPosition "zamerny"),   
[0,0,1]  
];  
}];

can someone please help 😃

i have the code from here

Share this post


Link to post
Share on other sites

I don't believe you can attach something to the weapon. A work around that some people have used is to attach it to the player's wrist. This option isn't perfect, but you can play around with it, and see how it works for what you want to do. 

Share this post


Link to post
Share on other sites
21 minutes ago, stburr91 said:

I don't believe you can attach something to the weapon. A work around that some people have used is to attach it to the player's wrist. This option isn't perfect, but you can play around with it, and see how it works for what you want to do. 

Actually you can.. Just test it

 

_object attachTo [player, [0,0,0], "proxy:\a3\characters_f\proxies\pistol.001"];

 

 

but my question is how to make the attached object face the weapondirection. 

Simulating a flashlight. 

 

ps. They added allot of "new" selectionPositions

Share this post


Link to post
Share on other sites

Try that (you need to add a switch on/off and a condition for handGun):

 

player setVariable ["MGIflLite","Reflector_Cone_01_Long_white_F" createVehicle [0,0,0]];  
(player getVariable "MGIflLite") attachTo [player, [0.1,0,0], "proxy:\a3\characters_f\proxies\pistol.001"];
 addMissionEventHandler ["EachFrame", {
    _wpnVecDir = player weaponDirection currentWeapon player;
    _p = asin (_wpnVecDir #2);
    _dir = (((_wpnVecDir #0) atan2 (_wpnVecDir #1)) + 360) mod 360;
    (player getVariable "MGIflLite") setVectorDirAndUp [
    [0,1,_wpnVecDir #2],[[0, -sin _p, cos _p], - _dir] call BIS_fnc_rotateVector2D];
}];

 

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites

this works very good thank you!

 

with this you can also create a gun-cam

Spoiler

player addWeapon "sgun_HunterShotgun_01_F"; 
player addPrimaryWeaponItem "2Rnd_12Gauge_Pellets";  
for "_i" from 1 to 3 do {player addItemToUniform "2Rnd_12Gauge_Pellets";};

player setVariable ["MGIflLite","Land_HandyCam_F" createVehicle [0,0,0]];    
(player getVariable "MGIflLite") attachTo [player, [0.127, 0, 0.08], "proxy:\a3\characters_f\proxies\weapon.001"];  
(player getVariable "MGIflLite") hideObject true; 
(player getVariable "MGIflLite") switchCamera "Internal"; 
 
 
 addMissionEventHandler ["EachFrame", {  
    _wpnVecDir = player weaponDirection currentWeapon player;  
    _p = asin (_wpnVecDir #2);  
    _dir = (((_wpnVecDir #0) atan2 (_wpnVecDir #1)) + 360) mod 360;  
    (player getVariable "MGIflLite") setVectorDirAndUp [  
    [0,1,_wpnVecDir #2],[[0, -sin _p, cos _p], - _dir] call BIS_fnc_rotateVector2D];  
}];

findDisplay 46 displayAddEventHandler ["MouseButtonDown", { 
 if (_this select 1 == 0) then { 
  player forceWeaponFire [currentMuzzle player, currentWeaponMode player]; 
 }; 
 false 
}]; 

findDisplay 46 displayAddEventHandler ["KeyDown", { 
 if (_this select 1 in actionKeys "ReloadMagazine") then { 
  reload player; 
 }; 
 false 
}];

 

 

  • 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

×