Entity::attachTo: Difference between revisions
No edit summary |
m (Small misspelling) |
||
| Line 1: | Line 1: | ||
Attaches entity1 to bone (boneIndex) of entity2.<br><br>boneIndex - this is different to boneID, use GET_Player_BONE_INDEX to get the index from the ID. use the index for attaching to specific bones. entity1 will be attached to entity2's centre if bone index given doesn't correspond to bone indexes for that entity type.<br><br>useSoftPinning - if set to false attached entity will not detach when fixed<br>collision - controls collision between the two entities (FALSE disables collision).<br>isPed - pitch doesnt work when false and roll will only work on negative numbers (only peds)<br>vertexIndex - position of vertex<br>fixedRot - if false it ignores entity vector <br><br> | Attaches entity1 to bone (boneIndex) of entity2.<br><br>boneIndex - this is different to boneID, use GET_Player_BONE_INDEX to get the index from the ID. use the index for attaching to specific bones. entity1 will be attached to entity2's centre if bone index given doesn't correspond to bone indexes for that entity type.<br><br>useSoftPinning - if set to false attached entity will not detach when fixed<br>collision - controls collision between the two entities (FALSE disables collision).<br>isPed - pitch doesnt work when false and roll will only work on negative numbers (only peds)<br>vertexIndex - position of vertex<br>fixedRot - if false it ignores entity vector <br><br> | ||
<b>Note:</b><br/> | <b>Note:</b><br/> | ||
On 1.1 you cannot | On 1.1 you cannot instantly attach an object to any entity after creating. You need to use it after a timeout (100-200 ms) or entityStreamIn. | ||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="javascript">entity.attachTo(entity2, boneIndex, xPosOffset, yPosOffset, zPosOffset, xRot, yRot, zRot, p9, useSoftPinning, collision, isPed, vertexIndex, fixedRot);</syntaxhighlight> | <syntaxhighlight lang="javascript">entity.attachTo(entity2, boneIndex, xPosOffset, yPosOffset, zPosOffset, xRot, yRot, zRot, p9, useSoftPinning, collision, isPed, vertexIndex, fixedRot);</syntaxhighlight> | ||
Revision as of 09:52, 24 May 2021
Attaches entity1 to bone (boneIndex) of entity2.
boneIndex - this is different to boneID, use GET_Player_BONE_INDEX to get the index from the ID. use the index for attaching to specific bones. entity1 will be attached to entity2's centre if bone index given doesn't correspond to bone indexes for that entity type.
useSoftPinning - if set to false attached entity will not detach when fixed
collision - controls collision between the two entities (FALSE disables collision).
isPed - pitch doesnt work when false and roll will only work on negative numbers (only peds)
vertexIndex - position of vertex
fixedRot - if false it ignores entity vector
Note:
On 1.1 you cannot instantly attach an object to any entity after creating. You need to use it after a timeout (100-200 ms) or entityStreamIn.
Syntax
entity.attachTo(entity2, boneIndex, xPosOffset, yPosOffset, zPosOffset, xRot, yRot, zRot, p9, useSoftPinning, collision, isPed, vertexIndex, fixedRot);
Required Arguments
- entity2: Entity handle ( so use for example player.handle )
- boneIndex: int
- xPosOffset: float
- yPosOffset: float
- zPosOffset: float
- xRot: float
- yRot: float
- zRot: float
- p9: Boolean
- useSoftPinning: Boolean
- collision: Boolean
- isPed: Boolean
- vertexIndex: int
- fixedRot: Boolean
Return value
- Undefined
Example
mp.events.add('arrestAttach', (cop, criminal) => {
criminal.attachTo(cop.handle, 0, 0, 0, 0, 0, 0, 0, true, false, false, false, 0, false);
});
See also
- mp.game.entity.doesExist
- mp.game.entity.doesBelongToThisScript
- mp.game.entity.doesHaveDrawable
- mp.game.entity.doesHavePhysics
- mp.game.entity.hasAnimFinished
- mp.game.entity.hasBeenDamagedByAnyObject
- mp.game.entity.hasBeenDamagedByAnyPed
- mp.game.entity.hasBeenDamagedByAnyVehicle
- mp.game.entity.hasBeenDamagedByEntity
- mp.game.entity.hasClearLosToEntity
- mp.game.entity.hasClearLosToEntity2
- mp.game.entity.hasClearLosToEntityInFront
- mp.game.entity.hasCollidedWithAnything
- mp.game.entity.getLastMaterialHitBy
- mp.game.entity.getCollisionNormalOfLastHitFor
- mp.game.entity.forceAiAndAnimationUpdate
- mp.game.entity.getAnimCurrentTime
- mp.game.entity.getAnimTotalTime
- mp.game.entity.getAnimDuration
- mp.game.entity.getEntityAnimDuration
- mp.game.entity.getAttachedTo
- mp.game.entity.getCoords
- mp.game.entity.getForwardVector
- mp.game.entity.getForwardX
- mp.game.entity.getForwardY
- mp.game.entity.getHeading
- mp.game.entity.getPhysicsHeading
- mp.game.entity.getHealth
- mp.game.entity.getMaxHealth
- mp.game.entity.setMaxHealth
- mp.game.entity.getHeight
- mp.game.entity.getHeightAboveGround
- mp.game.entity.getMatrix
- mp.game.entity.getModel
- mp.game.entity.getOffsetFromGivenWorldCoords
- mp.game.entity.getOffsetFromInWorldCoords
- mp.game.entity.getPitch
- mp.game.entity.getQuaternion
- mp.game.entity.getRoll
- mp.game.entity.getRotation
- mp.game.entity.getRotationVelocity
- mp.game.entity.getScript
- mp.game.entity.getSpeed
- mp.game.entity.getSpeedVector
- mp.game.entity.getUprightValue
- mp.game.entity.getVelocity
- mp.game.entity.getObjectIndexFromIndex
- mp.game.entity.getPedIndexFromIndex
- mp.game.entity.getVehicleIndexFromIndex
- mp.game.entity.getWorldPositionOfBone
- mp.game.entity.getNearestPlayerTo
- mp.game.entity.getNearestPlayerToOnTeam
- mp.game.entity.getType
- mp.game.entity.getPopulationType
- mp.game.entity.isAn
- mp.game.entity.isAnEntity
- mp.game.entity.isAPed
- mp.game.entity.isAMissionEntity
- mp.game.entity.isAVehicle
- mp.game.entity.isAnObject
- mp.game.entity.isAtCoord
- mp.game.entity.isAtEntity
- mp.game.entity.isAttached
- mp.game.entity.isAttachedToAnyObject
- mp.game.entity.isAttachedToAnyPed
- mp.game.entity.isAttachedToAnyVehicle
- mp.game.entity.isAttachedToEntity
- mp.game.entity.isDead
- mp.game.entity.isInAir
- mp.game.entity.isInAngledArea
- mp.game.entity.isInArea
- mp.game.entity.isInZone
- mp.game.entity.isInWater
- mp.game.entity.getSubmergedLevel
- mp.game.entity.isOnScreen
- mp.game.entity.isPlayingAnim
- mp.game.entity.isStatic
- mp.game.entity.isTouchingEntity
- mp.game.entity.isTouchingModel
- mp.game.entity.isUpright
- mp.game.entity.isUpsidedown
- mp.game.entity.isVisible
- mp.game.entity.isVisibleToScript
- mp.game.entity.isOccluded
- mp.game.entity.wouldBeOccluded
- mp.game.entity.wouldEntityBeOccluded
- mp.game.entity.isWaitingForWorldCollision
- mp.game.entity.applyForceToCenterOfMass
- mp.game.entity.applyForceTo
- mp.game.entity.attachToEntity
- mp.game.entity.attachBoneToEntityBone
- mp.game.entity.attachBoneToEntityBonePhysically
- mp.game.entity.attachToEntityPhysically
- mp.game.entity.processAttachments
- mp.game.entity.getBoneIndexByName
- mp.game.entity.clearLastDamageEntity
- mp.game.entity.delete
- mp.game.entity.detach
- mp.game.entity.freezePosition
- mp.game.entity.setCleanupByEngine
- mp.game.entity.playAnim
- mp.game.entity.playSynchronizedAnim
- mp.game.entity.playSynchronizedMapAnim
- mp.game.entity.playSynchronizedMapEntityAnim
- mp.game.entity.stopSynchronizedMapAnim
- mp.game.entity.stopSynchronizedMapEntityAnim
- mp.game.entity.stopAnim
- mp.game.entity.stopSynchronizedAnim
- mp.game.entity.hasAnimEventFired
- mp.game.entity.findAnimEventPhase
- mp.game.entity.setAnimCurrentTime
- mp.game.entity.setAnimSpeed
- mp.game.entity.setAsMissionEntity
- mp.game.entity.setAsNoLongerNeeded
- mp.game.entity.setPedAsNoLongerNeeded
- mp.game.entity.setVehicleAsNoLongerNeeded
- mp.game.entity.setObjectAsNoLongerNeeded
- mp.game.entity.setCanBeDamaged
- mp.game.entity.getCanBeDamaged
- mp.game.entity.setCanBeDamagedByRelationshipGroup
- mp.game.entity.setCanBeTargetedWithoutLos
- mp.game.entity.setCollision
- mp.game.entity.getCollisionDisabled
- mp.game.entity.setCompletelyDisableCollision
- mp.game.entity.setCoords
- mp.game.entity.setCoordsWithoutPlantsReset
- mp.game.entity.setCoordsNoOffset
- mp.game.entity.setDynamic
- mp.game.entity.setHeading
- mp.game.entity.setHealth
- mp.game.entity.setInvincible
- mp.game.entity.setIsTargetPriority
- mp.game.entity.setLights
- mp.game.entity.setLoadCollisionFlag
- mp.game.entity.hasCollisionLoadedAround
- mp.game.entity.setMaxSpeed
- mp.game.entity.setOnlyDamagedByPlayer
- mp.game.entity.setOnlyDamagedByRelationshipGroup
- mp.game.entity.setProofs
- mp.game.entity.getProofs
- mp.game.entity.setQuaternion
- mp.game.entity.setRecordsCollisions
- mp.game.entity.setRotation
- mp.game.entity.setVisible
- mp.game.entity.setVelocity
- mp.game.entity.setAngularVelocity
- mp.game.entity.setHasGravity
- mp.game.entity.setLodDist
- mp.game.entity.getLodDist
- mp.game.entity.setAlpha
- mp.game.entity.getAlpha
- mp.game.entity.resetAlpha
- mp.game.entity.setAlwaysPrerender
- mp.game.entity.setRenderScorched
- mp.game.entity.setTrafficlightOverride
- mp.game.entity.createModelSwap
- mp.game.entity.removeModelSwap
- mp.game.entity.createModelHide
- mp.game.entity.createModelHideExcludingScriptObjects
- mp.game.entity.removeModelHide
- mp.game.entity.createForcedObject
- mp.game.entity.removeForcedObject
- mp.game.entity.setNoCollisionEntity
- mp.game.entity.setMotionBlur
- mp.game.entity.setCanAutoVaultOn
- mp.game.entity.setCanClimbOn
- mp.game.entity.setDecalsDisabled
- mp.game.entity.getBoneRotation
- mp.game.entity.getBonePosition2
- mp.game.entity.getBoneRotationLocal
- mp.game.entity.getBoneCount
- mp.game.entity.enableUnk
- mp.game.entity.getPickup