Entity/SetParent

From Garry's Mod
Revision as of 12:17, 8 April 2017 by EstevanTH (Talk | contribs)
Jump to: navigation, search
 Entity:SetParent( )

Description

Sets the parent of this entity, making it move with its parent.

If an Entity is solid, it probably has a PhysObj. The Entity:Spawn method creates a static PhysObj for a few classes such as solid prop_dynamic, which will never move without the entity it belongs to. Otherwise it creates a dynamic PhysObj, which will fall on the ground when pushed or when the parent moves! Entity:PhysicsInit always creates a dynamic PhysObj whatever the class is. One solution for children with a dynamic PhysObj is to destroy it with Entity:PhysicsDestroy() and make sure to avoid Players colliding with them with Entity:PhysicsDestroy( COLLISION_GROUP_WEAPON ), otherwise Players can get stuck when touching the child.

Arguments

Entity parent

The entity to parent to. Setting this to nil will clear the parent.

Arguments

number attachmentId=-1

The attachment id to use when parenting, defaults to -1 or whatever the parent had set previously.

NOTE

You must call Entity:SetMoveType( MOVETYPE_NONE ) on the child for this argument to have any effect!

Personal tools
Navigation