attachTo

From Bohemia Interactive Community
Revision as of 09:55, 19 September 2013 by Killzone Kid (talk | contribs)
Jump to navigation Jump to search
Hover & click on the images for description

Description

Description:
Attaches an object to another object. The offset is applied to the object center unless a memory point is provided. If no offset is specified, the offset used will be the current relative positioning of objects against each other.
Multiplayer:
Only has to be executed on one client.
Groups:
Uncategorised

Syntax

Syntax:
Object attachTo [TObject, Offset, MemPoint]
Parameters:
Object: Object or player
TObject: Object or player
Offset: Array - format Position - (optional)
MemPoint: String - (optional), see ArmA: Selection Translations for czech selections names
Return Value:
Nothing

Examples

Example 1:
player attachTo [car,[0,0,1]]; 
Example 2:
player attachTo [tank,[0,-1,0],"Usti hlavne"]; 
Example 3:
Automatic offset: ammoCrate attachTo [player];
Example 4:
To set orientation of attached object use setVectorDirAndUp command: _expl1 = "DemoCharge_Remote_Ammo" createVehicle (position player); _expl1 attachTo [player, [-0.1,0.1,0.15],"Pelvis"]; _expl1 setVectorDirAndUp [[0.5,0.5,0],[-0.5,0.5,0]]; _expl2 = "DemoCharge_Remote_Ammo" createVehicle (position player); _expl2 attachTo [player, [0,0.15,0.15],"Pelvis"]; _expl2 setVectorDirAndUp [[1,0,0],[0,1,0]]; _expl3 = "DemoCharge_Remote_Ammo" createVehicle (position player); _expl3 attachTo [player, [0.1,0.1,0.15],"Pelvis"]; _expl3 setVectorDirAndUp [[0.5,-0.5,0],[0.5,0.5,0]]; Sbomber.jpg

Additional Information

See also:
detach

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note

Notes

Posted on June 6, 2009 - 13:47
IceShade
You can use setDir to change the direction of the attached object. The direction is relative to the object you attach it to, so setDir 180 won't point to the south but to the rear of the object you attach it to. Use setPos to synchronize the direction of the object in a network game. Example code: Object setDir 180; Object setpos getpos Object;
Posted on September 17, 2011 - 19:20
teaCup
Some objects you cannot attach anything to. To be more precise, you can attach objects to them, but the behaviour is unexpected. For instance: SuitcaseObject attachTo [FoldingTableObject, [0,0,0]]; You would expect the suitcase to jump to the pivot point of the table, and stick to it. Instead, the suitcase will freeze in it's original position. Even if the table is moved, the suitcase will be unaffected: it will not follow the table, it will not even respond to actions it reacted to prior to being attached: pushing, being shot at, etc.. It's just an object frozen in space. In MP it's even weirder, the suitcase would turn invisible. Dodgy objects when it comes to attaching things to them: most in Objects(small), Objects(signs), all of Objects(helpers) categories, etc..

Bottom Section