Page tree
Skip to end of metadata
Go to start of metadata


Introduced in

Version:1.00

Description

Description:

Attaches an object to another object, either at a fixed position relative to one object (for example, always 2m in front), or using a rope to bound the two. When attaching a camera, only the first 3 parameters apply (child, parent, offset).

Note: In V1.34+, the command can be re-applied to an already attached item (with new offsets), without having to detach it first.

Syntax

Syntax:child attachTo [parent, offset, mempoint, rope, bone, collisions]
Parameters:
  • child: Object - Object to be attached.
  • parent: Object - Object that the child is attached to. In V3.2+, objects can be attached to simulated proxies, by using the getProxy command.
  • offset: Position3D - Positional offset to either the object center or the memory point. If no offset is specified, the object is attached with the current position it is placed at (optional).
  • mempoint: String - Parent object Memory point (see Memory LOD in the VBS Developer Reference) (optional).
  • rope: Number or Boolean - Can be:
    • 0 or false: The attachment is rigid, meaning the child object is fixed in position relatively to the parent object (default: false).
    • 1 or true: The attachment is done using a flexible rope, allowing the child object to swing about.
    • 2: The object is attached using an inflexible link (such as a tow bar, with pivots on each end).
    • 3: The object is attached using a horizontal rope (to simulate towing). If the model has a "attachRope" memory point, then the rope is attached to this point.
  • bone: String - Name of bone to attach to on the parent object. The referenced bone must be of a "Memory", "Geometry", or "Fire" LOD (optional, available in V1.24+).
  • collisions: Boolean - Whether collisions for attached object should be enabled (optional, default: false, V1.40+).
Return Value:Nothing

Examples

Examples:
player attachTo [car,[0,2,0],"hatch1"]
camera attachTo [car, car selectionPosition "light_1_1_pos"]

Demo mission that attaches several boxes to a vehicle: attachTo.zip
Mission to help find attachment positions: attachToHelper.Intro.zip

Additional Information

See also: detach, isAttached, fn vbs positionObjectRelToObject, camSetAttachedLookDir, camSetBankIfAttached
Multiplayer:
Problems:

Notes







Posted on Feb 15, 2008
General Barron
Positional offset is in meters, and is in the format [right, front, up]. So [-3,4,1] means the object will be attached 3m to the left, 4m in front, and 1m above the host object.


Note that this is relative to the host object's 'vectorDir' and 'vectorUpDir'! So using the previous example, if we attached an object to a plane, and that plane was flying straight up in the air, the object would be 4m higher than the plane.

Also note that you may want to adjust the attached objects orientation after issuing the attachTo command, using the setVectorUp and setVectorDir commands.


Posted on Aug 23, 2010
Kuro
Mempoints for people are righthand, lefthand, head, neck, rightfoot, leftfoot, pelvis,...



Posted on Feb 16, 2011
Kronzky
Objects attached to GameLogics will not move along, if the GL travels along some waypoints.