attachTo: Difference between revisions
Jump to navigation
Jump to search
m (Added getRelPos to See also) |
Lou Montana (talk | contribs) (Add bone example, thanks to Ampersand on Discord) |
||
Line 52: | Line 52: | ||
|x4= To set orientation of attached object use [[setVectorDirAndUp]] command:<br> | |x4= To set orientation of attached object use [[setVectorDirAndUp]] command:<br> | ||
[[File:Sbomber.jpg| | [[File:Sbomber.jpg|300x200px|right]] | ||
<sqf> | <sqf> | ||
_expl1 = "DemoCharge_Remote_Ammo" createVehicle position player; | _expl1 = "DemoCharge_Remote_Ammo" createVehicle position player; | ||
Line 63: | Line 63: | ||
_expl3 attachTo [player, [0.1, 0.1, 0.15], "Pelvis"]; | _expl3 attachTo [player, [0.1, 0.1, 0.15], "Pelvis"]; | ||
_expl3 setVectorDirAndUp [[0.5, -0.5, 0], [0.5, 0.5, 0]]; | _expl3 setVectorDirAndUp [[0.5, -0.5, 0], [0.5, 0.5, 0]]; | ||
</sqf> | |||
|x5= [[File:arma3_attachTo-example-worker-drill-and-radio.png|300x200px|right]] | |||
<sqf> | |||
_drill attachTo [_worker, [0.0595885,-0.00950365,-0.13495], "RightForeArmRoll", true]; | |||
_drill setVectorDirAndUp [[0.536966,-0.00438141,-0.843605],[0.345872,0.913231,0.215406]]; | |||
_radio attachTo [_worker, [-0.100003,0.069064,0.153719], "Spine3", true]; | |||
_radio setVectorDirAndUp [[-0.144569,-0.48725,0.861354],[0.039712,0.866938,0.497072]]; | |||
</sqf> | </sqf> | ||
Line 68: | Line 76: | ||
}} | }} | ||
{{Note | |||
|user= TeaCup | |||
|timestamp= 20110917192000 | |||
|text= Some objects you cannot attach anything to. To be more precise, you can attach objects to them, but the behaviour is unexpected. For instance: | |||
Some objects you cannot attach anything to. To be more precise, you can attach objects to them, but the behaviour is unexpected. For instance: | |||
<sqf>SuitcaseObject attachTo [FoldingTableObject, [0,0,0]];</sqf> | <sqf>SuitcaseObject attachTo [FoldingTableObject, [0,0,0]];</sqf> | ||
You would expect the suitcase to jump to the pivot point of the table, and stick to it.<br> | You would expect the suitcase to jump to the pivot point of the table, and stick to it.<br> | ||
Instead, the suitcase will freeze in it is 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 is even weirder, the suitcase would turn invisible.<br> | Instead, the suitcase will freeze in it is 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 is even weirder, the suitcase would turn invisible.<br> | ||
Dodgy objects when it comes to attaching things to them: most in Objects (small), Objects (signs), all of Objects (helpers) categories, etc. | Dodgy objects when it comes to attaching things to them: most in Objects (small), Objects (signs), all of Objects (helpers) categories, etc. | ||
}} | |||
{{Note | |||
|user= Pixinger77 | |||
If you attach an explosive charge to an object (e.g. ammobox), the charge will not detonate when you simply set the damage to 1. You must detach it before. | |timestamp= 20140328162200 | ||
<sqf>private _target = myAmmoBox; | |text= If you attach an explosive charge to an object (e.g. ammobox), the charge will not detonate when you simply set the damage to 1. You must detach it before. | ||
<sqf> | |||
private _target = myAmmoBox; | |||
// create and attach charge | // create and attach charge | ||
private _charge = "DemoCharge_Remote_Ammo_Scripted" createVehicle position player; | private _charge = "DemoCharge_Remote_Ammo_Scripted" createVehicle position player; | ||
Line 91: | Line 98: | ||
// now detonate charge | // now detonate charge | ||
detach _charge; // Important! | detach _charge; // Important! | ||
_charge setDamage 1;</sqf> | _charge setDamage 1; | ||
</sqf> | |||
}} | |||
{{Note | |||
|user= ffur2007slx2_5 | |||
|timestamp= 20140601230000 | |||
|text= [[attachTo]] overwrites [[setVectorDirAndUp]] if attached obj was changed to attach another one. | |||
<sqf> | <sqf> | ||
_obj attachTo [_logic,[0, 0, 0]]; | _obj attachTo [_logic,[0, 0, 0]]; | ||
_obj setVectorDirAndUp [[0, 1, 0], [0, 0, -1]]; | _obj setVectorDirAndUp [[0, 1, 0], [0, 0, -1]]; | ||
_obj attachTo [_logic, [0, 0, 2]]; // vector no changes | _obj attachTo [_logic, [0, 0, 2]]; // vector no changes | ||
_obj attachTo [_anotherOne, [0, 0, 0]]; // vector changes to default | _obj attachTo [_anotherOne, [0, 0, 0]]; // vector changes to default | ||
</sqf> | </sqf> | ||
|game= arma3 | |||
|version= 1.20 | |||
}} | |||
Attaching an object does not update the accessibility of a place for the AI. The command '''should not''' be used for positioning large static objects - the AI will simply walk through such objects. | {{Note | ||
|user= ondrejkuzel | |||
|timestamp= 20140925100000 | |||
|text= Attaching an object does not update the accessibility of a place for the AI. The command '''should not''' be used for positioning large static objects - the AI will simply walk through such objects. | |||
}} | |||
Using [[attachTo]] with objects that have ragdoll physics (such as ammo boxes, containers, etc.) may cause unexpected behaviour. | |||
{{Note | |||
|user= Demellion | |||
|timestamp= 20160901175400 | |||
|text= Using [[attachTo]] with objects that have ragdoll physics (such as ammo boxes, containers, etc.) may cause unexpected behaviour. | |||
When you do so, if the attached object intersect origin object, origin object may gain some '''enormous collision properties''' even if the collision model for the attached object is not present localy to origin object, until detached. | When you do so, if the attached object intersect origin object, origin object may gain some '''enormous collision properties''' even if the collision model for the attached object is not present localy to origin object, until detached. | ||
Vehicles may start flipping with no mass calculation (ie tank might fly), player object might gain infinite Z-vector velocity on any interaction with terrain relief and other objects. | Vehicles may start flipping with no mass calculation (ie tank might fly), player object might gain infinite Z-vector velocity on any interaction with terrain relief and other objects. | ||
}} | |||
{{Note | |||
|user= R3vo | |||
|timestamp= 20190813125500 | |||
|text= When attaching an unit which is playing an animation to a static object, the animation becomes laggy. Presumably because the update frequency of the static object is used. | |||
When attaching an unit which is playing an animation to a static object, the animation becomes laggy. Presumably because the update frequency of the static object is used. | }} | ||
Revision as of 13:20, 13 October 2023
Description
- Description:
- Attaches an object to another object.
- The offset is applied to the object center unless a memory point is provided, in which case the offset will be applied to the memory point position.
- If no offset is specified, the current offset between the two objects will be used.
- Multiplayer:
- Use _attachedObj setPosWorld getPosWorld _attachedObj after setDir to synchronise set direction over the network (see setDir's page for its MP behaviour).
- Groups:
- Object Manipulation
Syntax
- Syntax:
- object1 attachTo [object2, offset, memPoint, followBoneRotation]
- Parameters:
- object1: Object - object to attach
- object2: Object - object to attach to
- offset: Array - (Optional) format PositionRelative
- memPoint: String - (Optional) see ArmA: Selection Translations for czech selections names
- since 2.02
- followBoneRotation: Boolean - (Optional) follows the memory point's rotation (if attached to one)
- Return Value:
- Nothing
Examples
- Example 1:
- Example 2:
- Example 3:
- Automatic offset:
- 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]]; - Example 5:
-
_drill attachTo [_worker, [0.0595885,-0.00950365,-0.13495], "RightForeArmRoll", true]; _drill setVectorDirAndUp [[0.536966,-0.00438141,-0.843605],[0.345872,0.913231,0.215406]]; _radio attachTo [_worker, [-0.100003,0.069064,0.153719], "Spine3", true]; _radio setVectorDirAndUp [[-0.144569,-0.48725,0.861354],[0.039712,0.866938,0.497072]];
Additional Information
- See also:
- attachedTo attachedObjects detach getRelPos attachObject attachedObject waypointAttachVehicle waypointAttachedVehicle lightAttachObject triggerAttachVehicle setVectorDir setVectorUp setVectorDirAndUp modelToWorld BIS_fnc_transformVectorDirAndUp
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
- Posted on Sep 17, 2011 - 19:20 (UTC)
-
Some objects you cannot attach anything to. To be more precise, you can attach objects to them, but the behaviour is unexpected. For instance:
You would expect the suitcase to jump to the pivot point of the table, and stick to it.SuitcaseObject attachTo [FoldingTableObject, [0,0,0]];
Instead, the suitcase will freeze in it is 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 is 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.
- Posted on Mar 28, 2014 - 16:22 (UTC)
-
If you attach an explosive charge to an object (e.g. ammobox), the charge will not detonate when you simply set the damage to 1. You must detach it before.
private _target = myAmmoBox; // create and attach charge private _charge = "DemoCharge_Remote_Ammo_Scripted" createVehicle position player; _charge attachTo [_target, [0, 0, 0.2]]; _charge setVectorDirAndUp [[0.5,0.5,0], [-0.5,0.5,0]]; // now detonate charge detach _charge; // Important! _charge setDamage 1;
- Posted on Jun 01, 2014 - 23:00 (UTC)
-
attachTo overwrites setVectorDirAndUp if attached obj was changed to attach another one.
_obj attachTo [_logic,[0, 0, 0]]; _obj setVectorDirAndUp [[0, 1, 0], [0, 0, -1]]; _obj attachTo [_logic, [0, 0, 2]]; // vector no changes _obj attachTo [_anotherOne, [0, 0, 0]]; // vector changes to default
- Posted on Sep 25, 2014 - 10:00 (UTC)
- Attaching an object does not update the accessibility of a place for the AI. The command should not be used for positioning large static objects - the AI will simply walk through such objects.
- Posted on Sep 01, 2016 - 17:54 (UTC)
- Using attachTo with objects that have ragdoll physics (such as ammo boxes, containers, etc.) may cause unexpected behaviour. When you do so, if the attached object intersect origin object, origin object may gain some enormous collision properties even if the collision model for the attached object is not present localy to origin object, until detached. Vehicles may start flipping with no mass calculation (ie tank might fly), player object might gain infinite Z-vector velocity on any interaction with terrain relief and other objects.
- Posted on Aug 13, 2019 - 12:55 (UTC)
- When attaching an unit which is playing an animation to a static object, the animation becomes laggy. Presumably because the update frequency of the static object is used.