Jump to content
M1ke_SK

[solved] attach objects in circle to barrel (setVectorDirAndUp)

Recommended Posts

I am trying to attach 4x DemoCharge to barrel to make a explosive bomb.
 
I have issue of understanding setVectorDirAndUp command. I managed to get 2 of 4 charges attach in right direction.
 
What array need to set for setVectorDirAndUp to face them right ?
 
Here is what I got so far:
 

fn_bomb.sqf

param ["_object"]; //Land_MetalBarrel_F

{
    _c4 = "DemoCharge_Remote_Ammo" createVehicle [(getPos _object) select 0, (getPos _object) select 1, 2];
    _c4 attachTo [_object, _x select 0];
    _c4 setVectorDirAndUp (_x select 1);
    _c4 enableSimulationGlobal false;
} forEach [
    [[0,0.3,0],  [[1,0,0],[0,1,0]]],
    [[0,-0.3,0], [[-1,0,0],[0,-1,0]]],
    [[0.3,0,0],  [[1,-1,0],[1,1,0]]], //fix
    [[-0.3,0,0], [[1,1,0],[-1,1,0]]] //fix
];

This is simple 4 objects so no angles involved. I would like to attach more c4s facing right direction to barrel if possible.

 

Share this post


Link to post
Share on other sites

I personally struggle with VectorDirAndUP...not a physics guy...so its all trial and error for me.  KK's blog post should help you though.

Share this post


Link to post
Share on other sites

_barrel = createVehicle [ "Land_MetalBarrel_F", player getPos [ 2, getDir player ], [], 0, "CAN_COLLIDE" ];

{

_x params[ "_offset", "_dirAndUp" ];

_c4 = createVehicle [ "DemoCharge_Remote_Ammo", [0,0,0], [], 0, "CAN_COLLIDE" ];

_c4 attachTo [ _barrel, _offset ];

_c4 setVectorDirAndUp _dirAndUp;

_c4 enableSimulationGlobal false;

} forEach [

[[0,0.3,0], [[1,0,0],[0,1,0]]],

[[0,-0.3,0], [[-1,0,0],[0,-1,0]]],

[[0.3,0,0], [[0,-1,0],[1,0,0]]],

[[-0.3,0,0], [[0,1,0],[-1,0,0]]]

];

  • 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

×