Garry's Mod Wiki
This is a list of all available methods for all entities, which includes Players, Weapons, NPCs and Vehicles.
For a list of possible members of Scripted Entities see ENT Structure
Methods
Entity:Activate()
Activates the entity. This needs to be used on some entities (like constraints) after being spawned.
For some entity types when this function is used after Entity:SetModelScale, the physics object will be recreated with the new scale. Source-sdk-2013.
Calling this method after Entity:SetModelScale will recreate a new scaled SOLID_VPHYSICS PhysObj on scripted entities. This can be a problem if you made a properly scaled PhysObj of another kind (using Entity:PhysicsInitSphere for instance) or if you edited the PhysObj's properties. This is especially the behavior of the Sandbox spawn menu.
Add a callback function to a specific event. This is used instead of hooks to avoid calling empty functions unnecessarily.
This also allows you to use certain hooks in engine entities (non-scripted entities).
This method does not check if the function has already been added to this object before, so if you add the same callback twice, it will be run twice! Make sure to add your callback only once.
Entity:AddEffects( number effect )
Applies an engine effect to an entity.
See also Entity:IsEffectActive and Entity:RemoveEffects.
Adds a gesture animation to the entity and plays it.
See Entity:AddGestureSequence and Entity:AddLayeredSequence for functions that takes sequences instead of ACT enum.
This function only works on BaseAnimatingOverlay entites!
Adds a gesture animation to the entity and plays it.
See Entity:AddGesture for a function that takes ACT enum.
See also Entity:AddLayeredSequence.
This function only works on BaseAnimatingOverlay entites!
Adds a gesture animation to the entity and plays it.
See Entity:AddGestureSequence for a function that doesn't take priority.
See Entity:AddGesture for a function that takes ACT enum.
This function only works on BaseAnimatingOverlay entites!
Entity:AddSolidFlags( number flags )
Adds solid flag(s) to the entity.
Entity:AddToMotionController( PhysObj physObj )
Adds a PhysObject to the entity's motion controller so that ENTITY:PhysicsSimulate will be called for given PhysObject as well.
You must first create a motion controller with Entity:StartMotionController.
You can remove added PhysObjects by using Entity:RemoveFromMotionController.
Only works on a scripted Entity of anim type
Returns an angle based on the ones inputted that you can use to align an object.
This function doesn't change the angle of the entity on its own (see example).
Entity Entity:BecomeRagdollOnClient()
Spawns a clientside ragdoll for the entity, positioning it in place of the original entity, and makes the entity invisible. It doesn't preserve flex values (face posing) as CSRagdolls don't support flex.
It does not work on players. Use Player:CreateRagdoll instead.
The original entity is not removed, and neither are any ragdolls previously generated with this function.
To make the entity re-appear, run Entity:SetNoDraw( false )
boolean Entity:BeingLookedAtByLocalPlayer()
Returns true if the entity is being looked at by the local player and is within 256 units of distance.
This function is only available in entities that are based off of sandbox's base_gmodentity.
This is used internally - although you're able to use it you probably shouldn't.
Dispatches blocked events to this entity's blocked handler. This function is only useful when interacting with entities like func_movelinear.
Returns a centered vector of this entity, NPCs use this internally to aim at their targets.
This only works on players and NPCs.
Returns whether the entity's bone has the flag or not.
Returns the length between given bone's position and the position of given bone's parent.
number Entity:BoundingRadius()
Returns the distance between the center of the bounding box and the furthest bounding box corner.
Calls all Entity:NetworkVarNotify functions with the given new value, but doesn't change the real value.
Causes a specified function to be run if the entity is removed by any means. This can later be undone by Entity:RemoveCallOnRemove if you need it to not run.
This hook is called clientside during full updates. See GM:EntityRemoved for more information.
Entity:ClearAllOutputs( string outputName = "nil" )
Clears all registered events for map I/O outputs on this entity. If a string is given, will use the string as a wildcard to limit removed outputs by name matches.
Entity:ClearPoseParameters()
Resets all pose parameters such as aim_yaw, aim_pitch and rotation.
Entity:CollisionRulesChanged()
Declares that the collision rules of the entity have changed, and subsequent calls for GM:ShouldCollide with this entity may return a different value than they did previously.
This function must not be called inside of GM:ShouldCollide. Instead, it must be called in advance when the condition is known to change. Failure to use this function correctly will result in a crash of the physics engine.
Entity:CreateBoneFollowers( table bone_whitelist = nil )
Creates bone followers based on the current entity model.
Bone followers are physics objects that follow the visual mesh. This is what is used by prop_dynamic for things like big combine doors for vehicles with multiple physics objects which follow the visual mesh of the door when it animates.
Be mindful that bone followers create a separate entity (phys_bone_follower) for each physics object.
You must call Entity:UpdateBoneFollowers every tick for bone followers to update their positions.
This function only works on anim, nextbot and ai type entities.
boolean Entity:CreatedByMap()
Returns whether the entity was created by map or not.
CNewParticleEffect Entity:CreateParticleEffect( string particle, number attachment, table options = nil )
Creates a clientside particle system attached to the entity. See also CreateParticleSystem
The particle effect must be precached with PrecacheParticleSystem and the file its from must be added via game. AddParticles before it can be used!
Entity:CreateShadow()
Draws the shadow of an entity.
Entity:DeleteOnRemove( Entity entityToRemove )
Whenever the entity is removed, entityToRemove will be removed also.
Entity:DestroyBoneFollowers()
Destroys bone followers created by Entity:CreateBoneFollowers.
This function only works on anim type entities.
Entity:DestroyShadow()
Removes the shadow for the entity.
The shadow will be recreated as soon as the entity wakes.
Doesn't affect shadows from flashlight/lamps/env_projectedtexture.
Entity:DisableMatrix( string matrixType )
Disables an active matrix.
Entity:DispatchTraceAttack( CTakeDamageInfo damageInfo, table traceRes, Vector dir = traceRes.HitNormal )
Performs a trace attack towards the entity this function is called on, as if an invisible bullet is shot towards it. Visually identical to Entity:TakeDamageInfo.
Calling this function on the victim entity in ENTITY:OnTakeDamage can cause infinite loops. This function correctly applies damage to func_breakable_surf entities, unlike Entity:TakeDamageInfo.
Entity:DontDeleteOnRemove( Entity entityToUnremove )
This removes the argument entity from an ent's list of entities to 'delete on remove'
Also see Entity:DeleteOnRemove
Draws the entity or model.
If called inside ENTITY:Draw or ENTITY:DrawTranslucent, it only draws the entity's model itself.
If called outside of those hooks, it will call both of said hooks depending on Entity:GetRenderGroup, drawing the entire entity again.
When drawing an entity more than once per frame in different positions, you should call Entity:SetupBones before each draw; Otherwise, the entity will retain its first drawn position.
This is a rendering function that requires a 3d rendering context.
This means that it will only work in 3d Rendering Hooks. Calling this on entities with EF_BONEMERGE and EF_NODRAW applied causes a crash. Issue Tracker: 1558Using this with a map model (game. GetWorld():GetModel()) crashes the game. Issue Tracker: 2688
Entity:DrawShadow( boolean shouldDraw )
Sets whether an entity's shadow should be drawn.
Entity:DropToFloor()
Move an entity down until it collides with something.
The entity needs to already have something below it within 256 units.
This is used internally - although you're able to use it you probably shouldn't.
You should use Entity:NetworkVar instead
Sets up a self. dt. NAME alias for a Data Table variable.
Entity:EmitSound( string soundName, number soundLevel = 75, number pitchPercent = 100, number volume = 1, number channel = CHAN_AUTO, CHAN_WEAPON for weapons, number soundFlags = 0, number dsp = 0, CRecipientFilter filter = nil )
Plays a sound on an entity. If run clientside, the sound will only be heard locally.
If used on a player or NPC character with the mouth rigged, the character will "lip-sync". This does not work with all sound files.
When using this function with weapons, use the Weapon itself as the entity, not its owner!This does not respond to SuppressHostEvents. Issue Tracker: 2651
Entity:EnableConstraints( boolean toggleConstraints )
Toggles the constraints of this ragdoll entity on and off.
Entity:EnableCustomCollisions()
Flags an entity as using custom lua defined collisions. Fixes entities having spongy player collisions or not hitting traces, such as after Entity:PhysicsFromMesh
Internally identical to Entity:AddSolidFlags( bit. bor( FSOLID_CUSTOMRAYTEST, FSOLID_CUSTOMBOXTEST ) )
Do not confuse this function with Entity:SetCustomCollisionCheck, they are not the same.
Can be used to apply a custom VMatrix to the entity, mostly used for scaling the model by a Vector.
To disable it, use Entity:DisableMatrix.
If your old scales are wrong due to a recent update, use Entity:SetLegacyTransform as a quick fix.
The matrix can also be modified to apply a custom rotation and offset via the VMatrix:SetAngles and VMatrix:SetTranslation functions. This does not scale procedural bones, and disables inverse kinematics of the entity. Issue Tracker: 3502
Gets the unique entity index of an entity.
Entity indices are marked as unused after deletion, and can be reused by newly-created entities
Entity:Extinguish()
Extinguishes the entity if it is on fire.
Has no effect if called inside GM:EntityTakeDamage (and the attacker is the flame that's hurting the entity)
See also Entity:Ignite.
Returns the direction a player, npc or ragdoll is looking as a world-oriented angle.
This can return an incorrect value in vehicles (like pods, buggy, . . . ). This bug has been fixed in the past but was causing many addons being broken, so the fix has been removed but applied to Player:GetAimVector only. Issue Tracker: 1150This may return local angles in jeeps when used with Player:EnterVehicle. A workaround is available in the second example. Issue Tracker: 2620
Searches for bodygroup with given name.
If called for Weapon (after Initialize hook) with different body groups on world model and view model will return value form view model.
Returns a transition from the given start and end sequence.
This function was only used by HL1 entities and NPCs, before the advent of sequence blending and gestures.
Entity:Fire( string input, string param = "nil", number delay = 0, Entity activator = nil, Entity caller = nil )
Fires an entity's input, conforming to the map IO event queue system. You can find inputs for most entities on the Valve Developer Wiki
See also Entity:Input for a function that bypasses the event queue and GM:AcceptInput.
Fires a bullet.
When used in a hook such as WEAPON:Think or WEAPON:PrimaryAttack, it will use Player:LagCompensation internally.
Lag compensation will not work if this function is called in a timer, regardless if the timer was made in a hook. Due to how FireBullets is set up internally, bullet tracers will always originate from attachment 1.
Makes an entity follow another entity's bone.
Internally this function calls Entity:SetParent( parent, boneid ), Entity:AddEffects( EF_FOLLOWBONE
) and sets an internal flag to always rebuild all bones.
If the entity vibrates or stops following the parent, you probably need to run Entity:SetPredictable( true ) clientside. This function will not work if the target bone's parent bone is invalid or if the bone is not used by VERTEX LOD0
Entity:ForcePlayerDrop()
Forces the Entity to be dropped, when it is being held by a player's gravitygun or physgun.
Entity:FrameAdvance()
Advances the cycle of an animated entity.
Animations that loop will automatically reset the cycle so you don't have to - ones that do not will stop animating once you reach the end of their sequence.
Do not call this function multiple times a frame, as it can cause unexpected results, such as animations playing at increased rate, etc.
NextBot:BodyMoveXY calls this internally, so do not call this function before or after NextBot:BodyMoveXY.
Vector Entity:GetAbsVelocity()
Returns the entity's velocity.
Actually binds to CBaseEntity::GetLocalVelocity() which retrieves the velocity of the entity due to its movement in the world from forces such as gravity. Does not include velocity from entity-on-entity collision.
Gets the angles of given entity.
This returns incorrect results for the local player clientside. Issue Tracker: 2764This will return the local player's EyeAngles in rendering hooks. Issue Tracker: 3106This will return Angle(0,0,0) in rendering hooks while paused in single-player. Issue Tracker: 3107
number Entity:GetAnimCount()
Returns the amount of animations (not to be confused with sequences) the entity's model has. A sequence can consist of multiple animations.
See also Entity:GetAnimInfo
Returns a table containing the number of frames, flags, name, and FPS of an entity's animation ID.
Animation ID is not the same as sequence ID. See Entity:GetAnimCount
number Entity:GetAnimTime()
Returns the last time the entity had an animation update. Returns 0 if the entity doesn't animate.
number Entity:GetAnimTimeInterval()
Returns the amount of time since last animation.
Works only on CBaseAnimating entities.
Gets the orientation and position of the attachment by its ID, returns nothing if the attachment does not exist.
The update rate of this function is limited by the setting of ENT. AutomaticFrameAdvance for Scripted Entities!This will return improper values for viewmodels if used in GM:CalcView. Issue Tracker: 1255
table Entity:GetAttachments()
Returns a table containing all attachments of the given entity's model.
Returns an empty table or nil in case its model has no attachments.
This can have inconsistent results in single-player. Issue Tracker: 3167
Vector Entity:GetBaseVelocity()
Returns the entity's base velocity which is their velocity due to forces applied by other entities. This includes entity-on-entity collision or riding a treadmill.
number Entity:GetBloodColor()
Returns the blood color of this entity. This can be set with Entity:SetBloodColor.
Gets the exact value for specific bodygroup of given entity.
If called for Weapon (after Initialize hook) with different body groups on world model and view model will return value form view model.
Returns the count of possible values for this bodygroup.
This is not the maximum value, since the bodygroups start with 0, not 1.
If called for Weapon (after Initialize hook) with different body groups on world model and view model will return value form view model.
Gets the name of specific bodygroup for given entity.
If called for Weapon (after Initialize hook) with different body groups on world model and view model will return value form view model.
table Entity:GetBodyGroups()
Returns a list of all body groups of the entity.
If called for Weapon (after Initialize hook) with different body groups on world model and view model will return body groups form view model.
Returns the contents of the specified bone.
Returns the value of the bone controller with the specified ID.
This is the precursor of pose parameters, and only works for Half Life 1: Source models supporting it.
number Entity:GetBoneCount()
Returns the amount of bones in the entity.
Will return 0 for ClientsideModel or undrawn entities until Entity:SetupBones is called on the entity.
Returns the transformation matrix of a given bone on the entity's model. The matrix contains the transformation used to position the bone in the world. It is not relative to the parent bone.
This is equivalent to constructing a VMatrix using Entity:GetBonePosition.
This can return the server's matrix during server lag. Issue Tracker: 884This can return garbage serverside or a 0,0,0 fourth column (represents position) for v49 models. Issue Tracker: 3285
Returns name of given bone id.
Returns parent bone of given bone.
Will return -1 for ClientsideModel until Entity:SetupBones is called on the entity.
Returns the position and angle of the given attachment, relative to the world.
This function can return entity's GetPos() instead if the entity doesn't have it's bone cache set up.
To ensure the bone position is correct use this:
local pos = ent:GetBonePosition(0)
if pos == ent:GetPos() then
pos = ent:GetBoneMatrix(0):GetTranslation()
endThis function returns the bone position from the last tick, so if your framerate is higher than the server's tickrate it may appear to lag behind if used on a fast moving entity. You can fix this by using the bone's matrix instead:
local matrix = entity:GetBoneMatrix(0)
local pos = matrix:GetTranslation()
local ang = matrix:GetAngles()This can return the server's position during server lag. Issue Tracker: 884This can return garbage serverside or Vector(0,0,0) for v49 models. Issue Tracker: 3285This can return garbage if a trace passed through the target bone during bone matrix access. Issue Tracker: 3739
Returns the surface property of the specified bone.
Returns info about given plane of non-nodraw brush model surfaces of the entity's model. Works on worldspawn as well.
This only works on entities with brush models.
number Entity:GetBrushPlaneCount()
Returns the amount of planes of non-nodraw brush model surfaces of the entity's model.
table Entity:GetBrushSurfaces()
Returns a table of brushes surfaces for brush model entities.
Returns the specified hook callbacks for this entity added with Entity:AddCallback
The callbacks can then be removed with Entity:RemoveCallback.
Returns ids of child bones of given bone.
table Entity:GetChildren()
Gets the children of the entity - that is, every entity whose move parent is this entity.
This function returns Entity:SetMoveParent children, NOT Entity:SetParent!
Entity:SetParent however also calls Entity:SetMoveParent.
This means that some entities in the returned list might have a NULL Entity:GetParent.
This also means that using this function on players will return their weapons on the client but not the server.
Returns the classname of a entity. This is often the name of the Lua file or folder containing the files for the entity
Returns an entity's collision bounding box. In most cases, this will return the same bounding box as Entity:GetModelBounds unless the entity does not have a physics mesh or it has a PhysObj different from the default.
This can be out-of-sync between the client and server for weapons. Issue Tracker: 223
number Entity:GetCollisionGroup()
Returns the entity's collision group
Returns the color the entity is set to without using a color object.
This is used internally - although you're able to use it you probably shouldn't.
Internally used to implement Entity:GetColor.
Returns the two entities involved in a constraint ent, or nil if the entity is not a constraint.
Returns the two entities physobjects involved in a constraint ent, or no value if the entity is not a constraint.
number Entity:GetCreationID()
Returns entity's creation ID. Unlike Entity:EntIndex or Entity:MapCreationID.
It will increase up until value of 10 000 000, at which point it will reset back to 0.
number Entity:GetCreationTime()
Returns the time the entity was created on, relative to CurTime.
Player Entity:GetCreator()
Gets the creator of the SENT.
boolean Entity:GetCustomCollisionCheck()
Returns whether this entity uses custom collision check set by Entity:SetCustomCollisionCheck.
Returns the frame of the currently played sequence. This will be a number between 0 and 1 as a representation of sequence progress.
This is used internally - although you're able to use it you probably shouldn't.
This is called internally by the Entity:NetworkVar system, you can use this in cases where using NetworkVar is not possible.
Get an angle stored in the datatable of the entity.
This is used internally - although you're able to use it you probably shouldn't.
This is called internally by the Entity:NetworkVar system, you can use this in cases where using NetworkVar is not possible.
Get a boolean stored in the datatable of the entity.
This is used internally - although you're able to use it you probably shouldn't.
This is called internally by the Entity:NetworkVar system, you can use this in cases where using NetworkVar is not possible.
Returns an entity stored in the datatable of the entity.
This is used internally - although you're able to use it you probably shouldn't.
This is called internally by the Entity:NetworkVar system, you can use this in cases where using NetworkVar is not possible.
Get a float stored in the datatable of the entity.
This is used internally - although you're able to use it you probably shouldn't.
This is called internally by the Entity:NetworkVar system, you can use this in cases where using NetworkVar is not possible.
Get an integer stored in the datatable of the entity.
This is used internally - although you're able to use it you probably shouldn't.
This is called internally by the Entity:NetworkVar system, you can use this in cases where using NetworkVar is not possible.
Get a string stored in the datatable of the entity.
This is used internally - although you're able to use it you probably shouldn't.
This is called internally by the Entity:NetworkVar system, you can use this in cases where using NetworkVar is not possible.
Get a vector stored in the datatable of the entity.
table Entity:GetEditingData()
Returns internal data about editable Entity:NetworkVars.
This is used internally by DEntityProperties and Editable Entities system.
This function will only work on entities which had Entity:InstallDataTable called on them, which is done automatically for players and all Scripted Entities
number Entity:GetEffects()
Returns a bit flag of all engine effect flags of the entity.
number Entity:GetElasticity()
Returns the elasticity of this entity, used by some flying entities such as the Helicopter NPC to determine how much it should bounce around when colliding.
Returns acceptable value range for the flex.
Returns the ID of the flex based on the beginning or the entire name.
Returns flex name.
number Entity:GetFlexNum()
Returns the number of flex controllers this entity's model has.
Please note that while this function can return the real number of flex controllers, the game supports only a certain amount due to networking limitations. See Entity:SetFlexWeight.
number Entity:GetFlexScale()
Returns the flex scale of the entity.
Returns flex controller type or "category". Used internally by Faceposer to categorize flex controllers.
Returns current weight ( value ) of given flex controller. Please see Entity:SetFlexWeight regarding limitations.
Vector Entity:GetForward()
Returns the forward vector of the entity, as a normalized direction vector
number Entity:GetFriction()
Returns the friction modifier for this entity. Entities default to 1 (100%) and can be higher.
number Entity:GetGravity()
Gets the gravity multiplier of the entity.
Entity Entity:GetGroundEntity()
Returns the object the entity is standing on.
Vector Entity:GetGroundSpeedVelocity()
Returns the entity's ground speed velocity, which is based on the entity's walk/run speed and/or the ground speed of their sequence ( Entity:GetSequenceGroundSpeed ). Will return an empty Vector if the entity isn't moving on the ground.
Gets the bone the hit box is attached to.
Gets the bounds (min and max corners) of a hit box.
Gets how many hit boxes are in a given hit box set.
number Entity:GetHitBoxGroupCount()
We advise against using this. It may be changed or removed in a future update.
You should use Entity:GetHitboxSetCount instead.
Returns the number of hit box sets that an entity has. Functionally identical to Entity:GetHitboxSetCount
Gets the hit group of a given hitbox in a given hitbox set.
Returns entity's current hit box set
number Entity:GetHitboxSetCount()
Returns the amount of hitbox sets in the entity.
An interface for accessing internal key values on entities.
See Entity:GetSaveTable for a more detailed explanation. See Entity:SetSaveValue for the opposite of this function.
table Entity:GetKeyValues()
Returns a table containing Hammer key values the entity has stored. Not all key values will be accessible this way. Use GM:EntityKeyValue or ENTITY:KeyValue to capture and store every key value.
Single key values can usually be retrieved with Entity:GetInternalVariable.
Here's a list of keyvalues that will not appear in this list, as they are not stored/defined as actual keyvalues internally:
rendercolor - Entity:GetColor (Only RGB)
rendercolor32 - Entity:GetColor (RGBA)
renderamt - Entity:GetColor (Alpha)
disableshadows - EF_NOSHADOW
mins - Entity:GetCollisionBounds
maxs - Entity:GetCollisionBounds
disablereceiveshadows - EF_NORECEIVESHADOW
nodamageforces - EFL_NO_DAMAGE_FORCES
angle - Entity:GetAngles
angles - Entity:GetAngles
origin - Entity:GetPos
targetname - Entity:GetName
Returns the animation cycle/frame for given layer.
This function only works on BaseAnimatingOverlay entities.
Returns the duration of given layer.
This function only works on BaseAnimatingOverlay entities.
Returns the layer playback rate. See also Entity:GetLayerDuration.
This function only works on BaseAnimatingOverlay entities.
Returns the sequence id of given layer.
This function only works on BaseAnimatingOverlay entities.
Returns the current weight of the layer. See Entity:SetLayerWeight for more information.
This function only works on BaseAnimatingOverlay entities.
Entity Entity:GetLightingOriginEntity()
Returns the entity that is being used as the light origin position for this entity.
Angle Entity:GetLocalAngles()
Returns the rotation of the entity relative to its parent entity.
Angle Entity:GetLocalAngularVelocity()
Returns the non-VPhysics angular velocity of the entity relative to its parent entity.
Vector Entity:GetLocalPos()
Returns entity's position relative to it's parent.
Gets the entity's angle manipulation of the given bone. This is relative to the default angle, so the angle is zero when unmodified.
Returns the jiggle amount of the entity's bone.
See Entity:ManipulateBoneJiggle for more info.
Gets the entity's position manipulation of the given bone. This is relative to the default position, so it is zero when unmodified.
Gets the entity's scale manipulation of the given bone. Normal scale is Vector( 1, 1, 1 )
string Entity:GetMaterial()
Returns the material override for this entity.
Returns an empty string if no material override exists. Use Entity:GetMaterials to list its default materials.
The server's value takes priority on the client. Issue Tracker: 3362
table Entity:GetMaterials()
Returns all materials of the entity's model.
This function is unaffected by Entity:SetSubMaterial as it returns the original materials.
The table returned by this function will not contain materials if they are missing from the disk/repository. This means that if you are attempting to find the ID of a material to replace with Entity:SetSubMaterial and there are missing materials on the model, all subsequent materials will be offset in the table, meaning that the ID you are trying to get will be incorrect.
number Entity:GetMaterialType()
Returns the surface material of this entity.
number Entity:GetMaxHealth()
Returns the max health that the entity was given. It can be set via Entity:SetMaxHealth.
Gets the model of given entity.
This does not necessarily return the model's path, as is the case for brush and virtual models. This is intentional behaviour, however, there is currently no way to retrieve the actual file path.
Returns the entity's model bounds, not scaled by Entity:SetModelScale.
These bounds are affected by all the animations the model has at compile time, if they go outside of the models' render bounds at any point.
See Entity:GetModelRenderBounds for just the render bounds of the model.
This is different than the collision bounds/hull, which are set via Entity:SetCollisionBounds.
number Entity:GetModelContents()
Returns the contents of the entity's current model.
number Entity:GetModelPhysBoneCount()
Gets the physics bone count of the entity's model. This is only applicable to anim type Scripted Entities with ragdoll models.
number Entity:GetModelRadius()
Gets the models radius.
Returns the entity's model render bounds. Unlike Entity:GetModelBounds, bounds returning by this function will not be affected by animations (at compile time).
number Entity:GetModelScale()
Gets the selected entity's model scale.
Returns the amount a momentary_rot_button entity is turned based on the given angle. 0 meaning completely turned closed, 1 meaning completely turned open.
This only works on momentary_rot_button entities.
number Entity:GetMoveCollide()
Returns the move collide type of the entity. The move collide is the way a physics object reacts to hitting an object - will it bounce, slide?
Entity Entity:GetMoveParent()
Returns the movement parent of this entity.
See Entity:SetMoveParent for more info.
number Entity:GetMoveType()
Returns the entity's movetype
Angle Entity:GetNetworkAngles()
Gets networked angles for entity.
Retrieves a networked angle value at specified index on the entity that is set by Entity:SetNetworked2Angle.
We advise against using this. It may be changed or removed in a future update.
You should be using Entity:GetNW2Angle instead.
Retrieves a networked boolean value at specified index on the entity that is set by Entity:SetNetworked2Bool.
We advise against using this. It may be changed or removed in a future update.
You should be using Entity:GetNW2Bool instead.
Retrieves a networked entity value at specified index on the entity that is set by Entity:SetNetworked2Entity.
We advise against using this. It may be changed or removed in a future update.
You should be using Entity:GetNW2Entity instead.
Retrieves a networked float value at specified index on the entity that is set by Entity:SetNetworked2Float.
We advise against using this. It may be changed or removed in a future update.
You should be using Entity:GetNW2Float instead.
Retrieves a networked integer (whole number) value that was previously set by Entity:SetNetworked2Int.
We advise against using this. It may be changed or removed in a future update.
You should be using Entity:GetNW2Int instead. The integer has a 32 bit limit. Use Entity:SetNWInt and Entity:GetNWInt instead
Retrieves a networked string value at specified index on the entity that is set by Entity:SetNetworked2String.
We advise against using this. It may be changed or removed in a future update.
You should be using Entity:GetNW2String instead.
Retrieves a networked value at specified index on the entity that is set by Entity:SetNetworked2Var.
We advise against using this. It may be changed or removed in a future update.
You should be using Entity:GetNW2Var instead.
We advise against using this. It may be changed or removed in a future update.
You should be using Entity:GetNW2VarProxy instead.
Returns callback function for given NWVar of this entity. Alias of Entity:GetNW2VarProxy
table Entity:GetNetworked2VarTable()
Returns all the networked2 variables in an entity.
We advise against using this. It may be changed or removed in a future update.
You should be using Entity:GetNW2VarTable instead.
Retrieves a networked vector value at specified index on the entity that is set by Entity:SetNetworked2Vector.
We advise against using this. It may be changed or removed in a future update.
You should be using Entity:GetNW2Vector instead.
We advise against using this. It may be changed or removed in a future update.
You should use Entity:GetNWAngle instead.
Retrieves a networked angle value at specified index on the entity that is set by Entity:SetNetworkedAngle.
We advise against using this. It may be changed or removed in a future update.
You should use Entity:GetNWBool instead.
Retrieves a networked boolean value at specified index on the entity that is set by Entity:SetNetworkedBool.
We advise against using this. It may be changed or removed in a future update.
You should use Entity:GetNWEntity instead.
Retrieves a networked float value at specified index on the entity that is set by Entity:SetNetworkedEntity.
We advise against using this. It may be changed or removed in a future update.
You should use Entity:GetNWFloat instead.
Retrieves a networked float value at specified index on the entity that is set by Entity:SetNetworkedFloat.
Seems to be the same as Entity:GetNetworkedInt.
We advise against using this. It may be changed or removed in a future update.
You should use Entity:GetNWInt instead.
Retrieves a networked integer value at specified index on the entity that is set by Entity:SetNetworkedInt.
We advise against using this. It may be changed or removed in a future update.
You should use Entity:GetNWString instead.
Retrieves a networked string value at specified index on the entity that is set by Entity:SetNetworkedString.
Retrieves a networked value at specified index on the entity that is set by Entity:SetNetworkedVar.
We advise against using this. It may be changed or removed in a future update.
This function was superseded by Entity:GetNetworked2VarProxy. This page still exists an archive in case anybody ever stumbles across old code and needs to know what it is
Returns callback function for given NWVar of this entity, previously set by Entity:SetNWVarProxy.
table Entity:GetNetworkedVarTable()
We advise against using this. It may be changed or removed in a future update.
You should be using Entity:GetNWVarTable instead.
Returns all the networked variables in an entity.
We advise against using this. It may be changed or removed in a future update.
You should use Entity:GetNWVector instead.
Retrieves a networked vector value at specified index on the entity that is set by Entity:SetNetworkedVector.
Vector Entity:GetNetworkOrigin()
Gets networked origin for entity.
table Entity:GetNetworkVars()
Returns all network vars created by Entity:NetworkVar and Entity:NetworkVarElement and their current values.
This is used internally by the duplicator. Entity type Network vars will not be returned!
For NWVars see Entity:GetNWVarTable.
This function will only work on entities which had Entity:InstallDataTable called on them, which is done automatically for players and all Scripted Entities
Returns if the entity's rendering and transmitting has been disabled.
This is equivalent to calling Entity:IsEffectActive( EF_NODRAW )
number Entity:GetNumBodyGroups()
Returns the body group count of the entity.
If called for Weapon (after Initialize hook) with different body groups on world model and view model will return value form view model.
number Entity:GetNumPoseParameters()
Returns the number of pose parameters this entity has.
Retrieves a networked angle value at specified index on the entity that is set by Entity:SetNW2Angle.
Retrieves a networked boolean value at specified index on the entity that is set by Entity:SetNW2Bool.
Retrieves a networked entity value at specified index on the entity that is set by Entity:SetNW2Entity.
Retrieves a networked float value at specified index on the entity that is set by Entity:SetNW2Float.
Retrieves a networked integer (whole number) value that was previously set by Entity:SetNW2Int.
The integer has a 32 bit limit. Use Entity:SetNWInt and Entity:GetNWInt instead
Retrieves a networked string value at specified index on the entity that is set by Entity:SetNW2String.
Retrieves a networked value at specified index on the entity that is set by Entity:SetNW2Var.
Returns callback function for given NWVar of this entity.
table Entity:GetNW2VarTable()
Returns all the NW2 variables in an entity.
This function will return keys with empty tables if the NW2Var is nil. Issue Tracker: 5396
Retrieves a networked vector value at specified index on the entity that is set by Entity:SetNW2Vector.
Retrieves a networked angle value at specified index on the entity that is set by Entity:SetNWAngle.
Retrieves a networked boolean value at specified index on the entity that is set by Entity:SetNWBool.
Retrieves a networked entity value at specified index on the entity that is set by Entity:SetNWEntity.
Retrieves a networked float value at specified index on the entity that is set by Entity:SetNWFloat.
Retrieves a networked integer (whole number) value that was previously set by Entity:SetNWInt.
This function will not round decimal values as it actually networks a float internally. Issue Tracker: 3374
Retrieves a networked string value at specified index on the entity that is set by Entity:SetNWString.
Returns callback function for given NWVar of this entity, previously set by Entity:SetNWVarProxy.
This function was superseded by Entity:GetNW2VarProxy. This page still exists an archive in case anybody ever stumbles across old code and needs to know what it is
table Entity:GetNWVarTable()
Returns all the networked variables in an entity.
Retrieves a networked vector value at specified index on the entity that is set by Entity:SetNWVector.
Returns the owner entity of this entity. See Entity:SetOwner for more info.
This function is generally used to disable physics interactions on projectiles being fired by their owner, but can also be used for normal ownership in case physics interactions are not involved at all. The Gravity gun will be able to pick up the entity even if the owner can't collide with it, the Physics gun however will not.
number Entity:GetParentAttachment()
Returns the attachment/bone index of the entity's parent. Returns 0 if the entity is not parented to an attachment/bone or if it isn't parented at all.
This is set by second argument of Entity:SetParent or the SetParentAttachment input.
number Entity:GetParentPhysNum()
If the entity is parented to an entity that has a model with multiple physics objects (like a ragdoll), this is used to retrieve what physics object number the entity is parented to on it's parent.
VMatrix Entity:GetParentWorldTransformMatrix()
Returns the position and angle of the entity's move parent as a 3x4 matrix (VMatrix is 4x4 so the fourth row goes unused). The first three columns store the angle as a rotation matrix, and the fourth column stores the position vector.
boolean Entity:GetPersistent()
Returns whether the entity is persistent or not.
See Entity:SetPersistent for more information on persistence.
Returns player who is claiming kills of physics damage the entity deals.
PhysObj Entity:GetPhysicsObject()
Returns the entity's physics object, if the entity has physics.
Entities don't have clientside physics objects by default, so this will return [NULL PHYSOBJ] on the client in most cases.
number Entity:GetPhysicsObjectCount()
Returns the number of physics objects an entity has (usually 1 for non-ragdolls)
Returns a specific physics object from an entity with multiple PhysObjects (like ragdolls)
See also Entity:TranslateBoneToPhysBone.
number Entity:GetPlaybackRate()
Returns the playback rate of the main sequence on this entity, with 1. 0 being the default speed.
Returns the pose parameter value
Returns name of given pose parameter
Returns pose parameter range
boolean Entity:GetPredictable()
Returns whether this entity is predictable or not.
See Entity:SetPredictable for more information
Called to override the preferred carry angles of this object.
This callback is only called for anim type entities.
Entity Entity:GetRagdollOwner()
Returns the entity which the ragdoll came from. The opposite of Player:GetRagdollEntity.
Angle Entity:GetRenderAngles()
Returns the entity's render angles, set by Entity:SetRenderAngles in a drawing hook.
Returns render bounds of the entity as local vectors. Can be overridden by Entity:SetRenderBounds.
If the render bounds are not inside players view, the entity will not be drawn!
number Entity:GetRenderFX()
Returns current render FX of the entity.
number Entity:GetRenderGroup()
Returns the render group of the entity.
number Entity:GetRenderMode()
Returns the render mode of the entity.
Vector Entity:GetRenderOrigin()
Returns the entity's render origin, set by Entity:SetRenderOrigin in a drawing hook.
Returns the rightward vector of the entity, as a normalized direction vector
Returns axis-aligned bounding box (AABB) of a orientated bounding box (OBB) based on entity's rotation.
Returns a table of save values for an entity.
These tables are not the same between the client and the server, and different entities may have different fields.
It is highly recommended to use Entity:GetInternalVariable for retrieving a single key of the save table for performance reasons.
You can get the list different fields an entity has by looking at it's source code (the 2013 SDK can be found online). Accessible fields are defined by each DEFINE_FIELD and DEFINE_KEYFIELD inside the DATADESC block.
Take the headcrab, for example:
BEGIN_DATADESC( CBaseHeadcrab )
// m_nGibCount - don't save
DEFINE_FIELD( m_bHidden, FIELD_BOOLEAN ),
DEFINE_FIELD( m_flTimeDrown, FIELD_TIME ),
DEFINE_FIELD( m_bCommittedToJump, FIELD_BOOLEAN ),
DEFINE_FIELD( m_vecCommittedJumpPos, FIELD_POSITION_VECTOR ),
DEFINE_FIELD( m_flNextNPCThink, FIELD_TIME ),
DEFINE_FIELD( m_flIgnoreWorldCollisionTime, FIELD_TIME ),
DEFINE_KEYFIELD( m_bStartBurrowed, FIELD_BOOLEAN, "startburrowed" ),
DEFINE_FIELD( m_bBurrowed, FIELD_BOOLEAN ),
DEFINE_FIELD( m_flBurrowTime, FIELD_TIME ),
DEFINE_FIELD( m_nContext, FIELD_INTEGER ),
DEFINE_FIELD( m_bCrawlFromCanister, FIELD_BOOLEAN ),
DEFINE_FIELD( m_bMidJump, FIELD_BOOLEAN ),
DEFINE_FIELD( m_nJumpFromCanisterDir, FIELD_INTEGER ),
DEFINE_FIELD( m_bHangingFromCeiling, FIELD_BOOLEAN ),
DEFINE_FIELD( m_flIlluminatedTime, FIELD_TIME ),
DEFINE_INPUTFUNC( FIELD_VOID, "Burrow", InputBurrow ),
DEFINE_INPUTFUNC( FIELD_VOID, "BurrowImmediate", InputBurrowImmediate ),
DEFINE_INPUTFUNC( FIELD_VOID, "Unburrow", InputUnburrow ),
DEFINE_INPUTFUNC( FIELD_VOID, "StartHangingFromCeiling", InputStartHangingFromCeiling ),
DEFINE_INPUTFUNC( FIELD_VOID, "DropFromCeiling", InputDropFromCeiling ),
// Function Pointers
DEFINE_THINKFUNC( EliminateRollAndPitch ),
DEFINE_THINKFUNC( ThrowThink ),
DEFINE_ENTITYFUNC( LeapTouch ),
END_DATADESC()
For each DEFINE_FIELD, the save table will have a key with name of first argument.
For each DEFINE_KEYFIELD, the save table will have a key with name of the third argument.
number Entity:GetSequence()
Return the index of the model sequence that is currently active for the entity.
Return activity id out of sequence id. Opposite of Entity:SelectWeightedSequence.
Returns the activity name for the given sequence id.
number Entity:GetSequenceCount()
Returns the amount of sequences ( animations ) the entity's model has.
Returns the ground speed of the entity's sequence.
Returns a table of information about an entity's sequence.
table Entity:GetSequenceList()
Returns a list of all sequences ( animations ) the model has.
Returns an entity's sequence move distance (the change in position over the course of the entire sequence).
See Entity:GetSequenceMovement for a similar function with more options.
boolean, Vector, Angle Entity:GetSequenceMovement( number sequenceId, number startCycle = 0, number endCyclnde = 1 )
Returns the delta movement and angles of a sequence of the entity's model.
Returns the change in heading direction in between the start and the end of the sequence.
Return the name of the sequence for the index provided.
Refer to Entity:GetSequence to find the current active sequence on this entity.
See Entity:LookupSequence for a function that does the opposite.
Returns an entity's sequence velocity at given animation frame.
boolean Entity:GetShouldPlayPickupSound()
Checks if the entity plays a sound when picked up by a player.
boolean Entity:GetShouldServerRagdoll()
Returns if entity should create a server ragdoll on death or a client one.
number Entity:GetSolidFlags()
Returns solid flag(s) of an entity.
boolean Entity:GetSpawnEffect()
Returns if we should show a spawn effect on spawn on this entity.
number Entity:GetSpawnFlags()
Returns the bitwise spawn flags used by the entity. These can be set by Entity:SetKeyValue.
Returns the material override for the given index.
Returns "" if no material override exists. Use Entity:GetMaterials to list it's default materials.
The server's value takes priority on the client. Issue Tracker: 3362
table Entity:GetSubModels()
Returns a list of models included into the entity's model in the . qc file.
Returns two vectors representing the minimum and maximum extent of the entity's axis-aligned bounding box for hitbox detection. In most cases, this will return the same bounding box as Entity:WorldSpaceAABB unless it was changed by Entity:SetSurroundingBounds or Entity:SetSurroundingBoundsType.
Returns a table that contains all lua-based key-value pairs saved on the Entity.
For retrieving engine-based key-value pairs, see Entity:GetSaveTable
table Entity:GetTouchTrace()
Returns the last trace used in the collision callbacks such as ENTITY:StartTouch, ENTITY:Touch and ENTITY:EndTouch.
This returns the last collision trace used, regardless of the entity that caused it. As such, it's only reliable when used in the hooks mentioned above
boolean Entity:GetTransmitWithParent()
Returns true if the TransmitWithParent flag is set or not.
boolean Entity:GetUnFreezable()
Returns if the entity is unfreezable, meaning it can't be frozen with the physgun. By default props are freezable, so this function will typically return false.
Retrieves a value from entity's Entity:GetTable. Set by Entity:SetVar.
Vector Entity:GetVelocity()
Returns the entity's velocity.
Actually binds to CBaseEntity::GetAbsVelocity() on the server and C_BaseEntity::EstimateAbsVelocity() on the client. This returns the total velocity of the entity and is equal to local velocity + base velocity. This can become out-of-sync on the client if the server has been up for a long time. Issue Tracker: 774
number Entity:GetWorkshopID()
We advise against using this. It may be changed or removed in a future update.
The function currently does nothing and always returns nil
Returns ID of workshop addon that the entity is from.
VMatrix Entity:GetWorldTransformMatrix()
Returns the position and angle of the entity as a 3x4 matrix (VMatrix is 4x4 so the fourth row goes unused). The first three columns store the angle as a rotation matrix, and the fourth column stores the position vector.
This returns incorrect results for the angular component (columns 1-3) for the local player clientside. Issue Tracker: 2764This will use the local player's EyeAngles in rendering hooks. Issue Tracker: 3106Columns 1-3 will be all 0 (angular component) in rendering hooks while paused in single-player. Issue Tracker: 3107
Causes the entity to break into its current models gibs, if it has any.
You must call Entity:PrecacheGibs on the entity before using this function, or it will not create any gibs.
If called on server, the gibs will be spawned on the currently connected clients and will not be synchronized. Otherwise the gibs will be spawned only for the client the function is called on.
this function will not remove or hide the entity it is called on.
For more expensive version of this function see Entity:GibBreakServer.
Entity:GibBreakServer( Vector force )
Causes the entity to break into its current models gibs, if it has any.
You must call Entity:PrecacheGibs on the entity before using this function, or it will not create any gibs.
The gibs will be spawned on the server and be synchronized with all clients.
Note, that this function will not remove or hide the entity it is called on.
This function is affected by props_break_max_pieces_perframe and props_break_max_pieces console variables.
Large numbers of serverside gibs will cause lag.
You can avoid this cost by spawning the gibs on the client using Entity:GibBreakClientDespite existing on client, it doesn't actually do anything on client.
boolean Entity:HasBoneManipulations()
Returns whether or not the bone manipulation functions have ever been called on given entity.
Related functions are Entity:ManipulateBonePosition, Entity:ManipulateBoneAngles, Entity:ManipulateBoneJiggle, and Entity:ManipulateBoneScale.
This will return true if the entity's bones have ever been manipulated. Resetting the position/angles/jiggle/scaling to 0,0,0 will not affect this function. Issue Tracker: 3131
boolean Entity:HasFlexManipulatior()
Returns whether or not the the entity has had flex manipulations performed with Entity:SetFlexWeight or Entity:SetFlexScale.
Returns whether this entity has the specified spawnflags bits set.
Returns the position of the head of this entity, NPCs use this internally to aim at their targets.
This only works on players and NPCs.
Sets the entity on fire.
See also Entity:Extinguish.
Entity:InitializeAsClientEntity()
We advise against using this. It may be changed or removed in a future update.
This function got disabled and will always throw an error if it's used. This is the error:
[ERROR] InitializeAsClientEntity is deprecated and should no longer be used.
Initializes this entity as being clientside only.
Only works on entities fully created clientside, and as such it currently has no use due to this being automatically called by ents. CreateClientProp, ents. CreateClientside, ClientsideModel and ClientsideScene.
Fires input to the entity with the ability to make another entity responsible, bypassing the event queue system.
You should only use this function over Entity:Fire if you know what you are doing.
See also Entity:Fire for a function that conforms to the internal map IO event queue and GM:AcceptInput for a hook that can intercept inputs.
Entity:InstallDataTable()
This is used internally - although you're able to use it you probably shouldn't.
Sets up Data Tables from entity to use with Entity:NetworkVar.
Entity:InvalidateBoneCache()
Resets the entity's bone cache values in order to prepare for a model change.
This should be called after calling Entity:SetPoseParameter.
boolean Entity:IsConstrained()
Returns true if the entity has constraints attached to it
This will only update clientside if the server calls it first. This only checks constraints added through the constraint so this will not react to map constraints.
For a serverside alternative, see constraint. HasConstraintsIssue Tracker: 3837
boolean Entity:IsConstraint()
Returns if entity is constraint or not
Returns whether the entity is dormant or not.
Client/server entities become dormant when they leave the PVS on the server. Client side entities can decide for themselves whether to become dormant.
This mainly applies to PVS (Potential Visibility Set).
Returns whether an entity has engine effect applied or not.
Checks if given flag is set or not.
Returns whether the entity is in the world (not inside a wall or outside of the map).
Internally this function uses util. IsInWorld, that means that this function only checks Entity:GetPos of the entity. If an entity is only partially inside a wall, or has a weird GetPos offset, this function may not give reliable output.
boolean Entity:IsLagCompensated()
Returns whether the entity is lag compensated or not.
Returns true if the target is in line of sight.
This will only work when called on CBaseCombatCharacter entities. This includes players, NPCs, grenades, RPG rockets, crossbow bolts, and physics cannisters.
boolean Entity:IsMarkedForDeletion()
Returns if the entity is going to be deleted in the next frame. Entities marked for deletion should not be accessed.
Checks if the entity is an NPC or not.
This will return false for NextBots, see Entity:IsNextBot for that.
boolean Entity:IsOnGround()
Returns whether the entity is on ground or not.
Internally, this checks if FL_ONGROUND is set on the entity.
This function is an alias of Entity:OnGround.
boolean Entity:IsPlayerHolding()
Returns true if the entity is being held by a player. Either by physics gun, gravity gun or use-key (+use).
If multiple players are holding an object and one drops it, this will return false despite the object still being held. Issue Tracker: 2046
Returns whether there's a gesture with the given activity being played.
This function only works on BaseAnimatingOverlay entites!
Returns whether a given point is within the entity's Orientated Bounding Box.
This relies on the entity having a collision mesh (not a physics object) and will be affected by SOLID_NONE.
boolean Entity:IsScripted()
Checks if the entity is a SENT or a built-in entity.
boolean Entity:IsSequenceFinished()
Returns whether the entity's current sequence is finished or not.
Returns if the entity is solid or not.
Very useful for determining if the entity is a trigger or not.
Returns whether the entity is a valid entity or not.
An entity is valid if:
It is not a NULL entity
It is not the worldspawn entity (game. GetWorld)
Instead of calling this method directly, it's a good idea to call the global IsValid instead, however if you're sure the variable you're using is always an entity object it's better to use this method
It will check whether the given variable contains an object (an Entity) or nothing at all for you. See examples.
NULL entities can still be assigned with key/value pairs, but they will be instantly negated. See example 3
This might be a cause for a lot of headache. Usually happening during networking etc. , when completely valid entities suddenly become invalid on the client, but are never filtered with IsValid(). See GM:InitPostEntity for more details.
Returns whether the given layer ID is valid and exists on this entity.
This function only works on BaseAnimatingOverlay entities.
Returns whether the entity is a widget or not.
This is used by the "Edit Bones" context menu property.
Converts a vector local to an entity into a worldspace vector
Converts a local angle (local to the entity) to a world angle.
Returns the attachment index of the given attachment name.
Gets the bone index of the given bone name, returns nil if the bone does not exist.
Returns pose parameter ID from its name.
Returns sequence ID from its name. See Entity:GetSequenceName for a function that does the opposite.
Entity:MakePhysicsObjectAShadow( boolean allowPhysicsMovement = true, boolean allowPhysicsRotation = true )
Turns the Entity:GetPhysicsObject into a physics shadow.
It's used internally for the Player's and NPC's physics object, and certain HL2 entities such as the crane.
A physics shadow can be used to have static entities that never move by setting both arguments to false.
Unlike Entity:PhysicsInitShadow, this function doesn't remove the current physics object.
Sets custom bone angles.
When used repeatedly serverside, this method is strongly discouraged due to the huge network traffic produced. Issue Tracker: 5148
Manipulates the bone's jiggle status. This allows non jiggly bones to become jiggly.
Sets custom bone offsets.
Sets custom bone scale.
When used repeatedly serverside, this method is strongly discouraged due to the huge network traffic produced. Issue Tracker: 5148This does not scale procedural bones. Issue Tracker: 3502
number Entity:MapCreationID()
Returns entity's map creation ID. Unlike Entity:EntIndex or Entity:GetCreationID, it will always be the same on same map, no matter how much you clean up or restart it.
To be used in conjunction with ents. GetMapCreatedEntity.
Entity:MarkShadowAsDirty()
Refreshes the shadow of the entity.
Entity:MuzzleFlash()
Fires the muzzle flash effect of the weapon the entity is carrying. This only creates a light effect and is often called alongside Weapon:SendWeaponAnim
Performs a Ray-Orientated Bounding Box intersection from the given position to the origin of the OBBox with the entity and returns the hit position on the OBBox.
This relies on the entity having a collision mesh (not a physics object) and will be affected by SOLID_NONE
Creates a network variable on the entity and adds Set/Get functions for it. This function should only be called in ENTITY:SetupDataTables.
See Entity:NetworkVarNotify for a function to hook NetworkVar changes.
Entity NetworkVars are influenced by the return value of ENTITY:UpdateTransmitState.
So if you use the PVS(default), then the NetworkVars can be different for each client. Make sure to not call the SetDT* and your custom set methods on the client realm unless you know exactly what you are doing.
Combining this function with util. TableToJSON can also provide a way to network tables as serialized strings.
Entity:NetworkVarElement( string type, number slot, string element, string name, table extended = nil )
Similarly to Entity:NetworkVar, creates a network variable on the entity and adds Set/Get functions for it. This method stores it's value as a member value of a vector or an angle. This allows to go beyond the normal variable limit of Entity:NetworkVar for Int and Float types, at the expense of Vector and Angle limit.
This function should only be called in ENTITY:SetupDataTables.
Make sure to not call the SetDT* and your custom set methods on the client realm unless you know exactly what you are doing.
Creates a callback that will execute when the given network variable changes - that is, when the Set<name>() function is run.
The callback is executed before the value is changed, and is called even if the new and old values are the same.
This function does not exist on entities in which Entity:InstallDataTable has not been called.
By default, this means this function only exists on SENTs (both serverside and clientside) and on players with a Player Class (serverside and clientside LocalPlayer only).
It's therefore safest to only use this in ENTITY:SetupDataTables.
The callback will not be called clientside if the var is changed right after entity spawn.
In the case of a scripted entity, this will cause the next ENTITY:Think event to be run at the given time.
Does not work clientside! Use Entity:SetNextClientThink instead.
This does not work with SWEPs or Nextbots. Issue Tracker: 3269
number Entity:ObjectCaps()
Returns the entity's capabilities as a bitfield.
In the engine this function is mostly used to check the use type, the save/restore system and level transitions flags.
Even though the function is defined shared, it is not guaranteed to return the same value across states.
The enums for this are not currently implemented in Lua, however you can access the defines here.
Returns true if the entity is on the ground, and false if it isn't.
Internally, this checks if FL_ONGROUND is set on the entity. This is only updated for players and NPCs, and thus won't inherently work for other entities.
Tests whether the damage passes the entity filter.
This will call ENTITY:PassesDamageFilter on scripted entities of the type "filter".
This function only works on entities of the type "filter". ( filter_* entities, including base game filter entites )
Tests whether the entity passes the entity filter.
This will call ENTITY:PassesFilter on scripted entities of the type "filter".
This function only works on entities of the type "filter". ( filter_* entities, including base game filter entites )
Entity:PhysicsDestroy()
Destroys the current physics object of an entity.
Cannot be used on a ragdoll or the world entity.
Initializes the physics mesh of the entity from a triangle soup defined by a table of vertices. The resulting mesh is hollow, may contain holes, and always has a volume of 0.
While this is very useful for static geometry such as terrain displacements, it is advised to use Entity:PhysicsInitConvex or Entity:PhysicsInitMultiConvex for moving solid objects instead.
Entity:EnableCustomCollisions needs to be called if you want players to collide with the entity correctly.
Initializes the physics object of the entity using its current model. Deletes the previous physics object if it existed and the new object creation was successful.
If the entity's current model has no physics mesh associated to it, no physics object will be created and the previous object will still exist, if applicable.
When called clientside, this will not create a valid PhysObj if the model hasn't been precached serverside.
If successful, this function will automatically call Entity:SetSolid( solidType ) and Entity:SetSolidFlags( 0 ). Clientside physics objects are broken and do not move properly in some cases. Physics objects should only created on the server or you will experience incorrect physgun beam position, prediction issues, and other unexpected behavior.
A workaround is available on the Entity:PhysicsInitConvex page. Issue Tracker: 5060
Makes the physics object of the entity a AABB.
This function will automatically destroy any previous physics objects and do the following:
Entity:SetSolid( SOLID_BBOX )
Entity:SetMoveType( MOVETYPE_VPHYSICS )
Entity:SetCollisionBounds( mins, maxs )
If the volume of the resulting box is 0 (the mins and maxs are the same), the mins and maxs will be changed to Vector( -1, -1, -1 ) and Vector( 1, 1, 1 ), respectively. Clientside physics objects are broken and do not move properly in some cases. Physics objects should only created on the server or you will experience incorrect physgun beam position, prediction issues, and other unexpected behavior.
A workaround is available on the Entity:PhysicsInitConvex page. Issue Tracker: 5060
Initializes the physics mesh of the entity with a convex mesh defined by a table of points. The resulting mesh is the of all the input points. If successful, the previous physics object will be removed.
This is the standard way of creating moving physics objects with a custom convex shape. For more complex, concave shapes, see Entity:PhysicsInitMultiConvex.
This will crash if given all Vector(0,0,0)s. Issue Tracker: 3301Clientside physics objects are broken and do not move properly in some cases. Physics objects should only created on the server or you will experience incorrect physgun beam position, prediction issues, and other unexpected behavior.
You can use the following workaround for movement, though clientside collisions will still be broken.
function ENT:Think()
if ( CLIENT ) then
local physobj = self:GetPhysicsObject()
if ( IsValid( physobj ) ) then
physobj:SetPos( self:GetPos() )
physobj:SetAngles( self:GetAngles() )
end
end
endIssue Tracker: 5060
An advanced version of Entity:PhysicsInitConvex which initializes a physics object from multiple convex meshes. This should be used for physics objects with a custom shape which cannot be represented by a single convex mesh.
If successful, the previous physics object will be removed.
Clientside physics objects are broken and do not move properly in some cases. Physics objects should only created on the server or you will experience incorrect physgun beam position, prediction issues, and other unexpected behavior.
A workaround is available on the Entity:PhysicsInitConvex page. Issue Tracker: 5060
boolean Entity:PhysicsInitShadow( boolean allowPhysicsMovement = true, boolean allowPhysicsRotation = true )
Initializes the entity's physics object as a physics shadow. Removes the previous physics object if successful. This is used internally for the Player's and NPC's physics object, and certain HL2 entities such as the crane.
A physics shadow can be used to have static entities that never move by setting both arguments to false.
The created physics object will depend on the entity's solidity SOLID_NONE will not create a physics object, SOLID_BBOX will create a Axis-Aligned BBox one, SOLID_OBB will create Orientated Bounding Box one, and anything else will use the models' physics mesh.
Clientside physics objects are broken and do not move properly in some cases. Physics objects should only created on the server or you will experience incorrect physgun beam position, prediction issues, and other unexpected behavior.
A workaround is available on the Entity:PhysicsInitConvex page. Issue Tracker: 5060
Makes the physics object of the entity a sphere.
This function will automatically destroy any previous physics objects and do the following:
Entity:SetSolid( SOLID_BBOX )
Entity:SetMoveType( MOVETYPE_VPHYSICS )
Clientside physics objects are broken and do not move properly in some cases. Physics objects should only created on the server or you will experience incorrect physgun beam position, prediction issues, and other unexpected behavior.
A workaround is available on the Entity:PhysicsInitConvex page. Issue Tracker: 5060
Initializes a static physics object of the entity using its current model. If successful, the previous physics object is removed.
This is what used by entities such as func_breakable, prop_dynamic, item_suitcharger, prop_thumper and npc_rollermine while it is in its "buried" state in the Half-Life 2 Campaign.
If the entity's current model has no physics mesh associated to it, no physics object will be created.
This function will automatically call Entity:SetSolid( solidType ). Clientside physics objects are broken and do not move properly in some cases. Physics objects should only created on the server or you will experience incorrect physgun beam position, prediction issues, and other unexpected behavior.
A workaround is available on the Entity:PhysicsInitConvex page. Issue Tracker: 5060
Entity:PhysWake()
Wakes up the entity's physics object
Makes the entity play a . vcd scene. All scenes from Half-Life 2.
Entity:PointAtEntity( Entity target )
Changes an entities angles so that it faces the target entity.
number Entity:PrecacheGibs()
Precaches gibs for the entity's model.
Normally this function should be ran when the entity is spawned, for example the ENTITY:Initialize, after Entity:SetModel is called.
This is required for Entity:GibBreakServer and Entity:GibBreakClient to work.
Entity:RagdollSolve()
Normalizes the ragdoll. This is used alongside Kinect in Entity:SetRagdollBuildFunction, for more info see ragdoll_motion entity.
Entity:RagdollStopControlling()
Sets the function to build the ragdoll. This is used alongside Kinect in Entity:SetRagdollBuildFunction, for more info see ragdoll_motion entity.
Entity:RagdollUpdatePhysics()
Makes the physics objects follow the set bone positions. This is used alongside Kinect in Entity:SetRagdollBuildFunction, for more info see ragdoll_motion entity.
Entity:Remove()
Removes the entity it is used on. The entity will be removed at the start of next tick.
Entity:RemoveAllDecals()
Removes all decals from the entities surface.
Entity:RemoveAllGestures()
Removes and stops all gestures.
This function only works on BaseAnimatingOverlay entites!
Removes a callback previously added with Entity:AddCallback
Entity:RemoveCallOnRemove( string identifier )
Removes a function previously added via Entity:CallOnRemove.
Entity:RemoveEffects( number effect )
Removes an engine effect applied to an entity.
Entity:RemoveEFlags( number flag )
Removes specified engine flag
Entity:RemoveFlags( number flag )
Removes specified flag(s) from the entity
Entity:RemoveFromMotionController( PhysObj physObj )
Removes a PhysObject from the entity's motion controller so that ENTITY:PhysicsSimulate will no longer be called for given PhysObject.
You must first create a motion controller with Entity:StartMotionController.
Only works on a scripted Entity of anim type
Entity:RemoveGesture( number activity )
Removes and stops the gesture with given activity.
This function only works on BaseAnimatingOverlay entites!
Entity:RemoveInternalConstraint( number num = -1 )
Breaks internal Ragdoll constrains, so you can for example separate an arm from the body of a ragdoll and preserve all physics.
The visual mesh will still stretch as if it was properly connected unless the ragdoll model is specifically designed to avoid that.
Entity:RemoveSolidFlags( number flags )
Removes solid flag(s) from the entity.
Entity:ResetSequence( number sequence )
Plays an animation on the entity. This may not always work on engine entities.
This will not reset the animation on viewmodels, use Entity:SendViewModelMatchingSequence instead. This will not work properly if called directly after calling Entity:SetModel. Consider waiting until the next Tick.
Will not work on players due to the animations being reset every frame by the base gamemode animation system. See GM:CalcMainActivity.
For custom scripted entities you will want to apply example from ENTITY:Think to make animations work.
Entity:ResetSequenceInfo()
Reset entity sequence info such as playback rate, ground speed, last event check, etc.
Entity:Respawn()
Makes the entity/weapon respawn.
Only usable on HL2/HL:S pickups and any weapons. Seems to be buggy with weapons.
Very unreliable.
Restarts the entity's animation gesture. If the given gesture is already playing, it will reset it and play it from the beginning.
This function only works on BaseAnimatingOverlay entites.
Entity:RestoreNetworkVars( table data )
Calls the associated Entity:Set* function for each network var provided.
This is used internally - although you're able to use it you probably shouldn't.
Used for the built-in duplicator, you do not need to call this yourself. This function will only work on entities which had Entity:InstallDataTable called on them, which is done automatically for players and all Scripted Entities
Returns sequence ID corresponding to given activity ID.
Opposite of Entity:GetSequenceActivity.
Similar to Entity:LookupSequence.
See also Entity:SelectWeightedSequenceSeeded.
Returns the sequence ID corresponding to given activity ID, and uses the provided seed for random selection. The seed should be the same server-side and client-side if used in a predicted environment.
See Entity:SelectWeightedSequence for a provided-seed version of this function.
Entity:SendViewModelMatchingSequence( number seq )
Sends sequence animation to the view model. It is recommended to use this for view model animations, instead of Entity:ResetSequence.
This function is only usable on view models.
Returns length of currently played sequence.
This will return incorrect results for weapons and viewmodels clientside in thirdperson. Issue Tracker: 2783
Entity:SetAbsVelocity( Vector velocity )
Sets the entity's velocity.
Actually binds to CBaseEntity::SetLocalVelocity() which sets the entity's velocity due to movement in the world from forces such as gravity. Does not include velocity from entity-on-entity collision or other world movement.
Sets the angles of the entity.
To set a player's angles, use Player:SetEyeAngles instead.
Entity:SetAnimation( number playerAnim )
Sets a player's third-person animation. Mainly used by Weapons to start the player's weapon attack and reload animations.
Entity:SetAnimTime( number time )
Sets the start time (relative to CurTime) of the current animation, which is used to determine Entity:GetCycle. Should be less than CurTime to play an animation from the middle.
We advise against using this. It may be changed or removed in a future update.
You should be using Entity:SetParent instead.
Parents the sprite to an attachment on another model.
Works only on env_sprite entities.
Despite existing on client, it doesn't actually do anything on client.
Entity:SetBloodColor( number bloodColor )
Sets the blood color this entity uses.
Sets an entities' bodygroup.
If called for Weapon (after Initialize hook) with different body groups on world model and view model, check will occur by view model.
Entity:SetBodyGroups( string bodygroups )
Sets the bodygroups from a string. A convenience function for Entity:SetBodygroup.
If called for Weapon (after Initialize hook) with different body groups on world model and view model, check will occur by view model.
Sets the specified value on the bone controller with the given ID of this entity, it's used in HL1 to change the head rotation of NPCs, turret aiming and so on.
This is the precursor of pose parameters, and only works for Half Life 1: Source models supporting it.
Sets the bone matrix of given bone to given matrix. See also Entity:GetBoneMatrix.
Despite existing serverside, it does nothing.
Sets the bone position and angles.
Sets the collision bounds for the entity, which are used for triggers (Entity:SetTrigger, ENTITY:Touch), and collision (If Entity:SetSolid set as SOLID_BBOX).
Input bounds are relative to Entity:GetPos!
See also Entity:SetCollisionBoundsWS.
Player collision bounds are reset every frame to player's Player:SetHull values.
A convenience function that sets the collision bounds for the entity in world space coordinates by transforming given vectors to entity's local space and passing them to Entity:SetCollisionBounds
Entity:SetCollisionGroup( number group )
Sets the entity's collision group.
Sets the color of an entity.
Some entities may need a custom render mode set for transparency to work. See example 2.
Entities also must have a proper render group set for transparency to work.
Sets the color of an entity without usage of a Color object.
This is used internally - although you're able to use it you probably shouldn't.
Used internally to implement Entity:SetColor.
Entity:SetCreator( Player ply )
Sets the creator of the Entity. This is set automatically in Sandbox gamemode when spawning SENTs, but is never used/read by default.
Entity:SetCustomCollisionCheck( boolean enable )
Marks the entity to call GM:ShouldCollide. Not to be confused with Entity:EnableCustomCollisions.
Sets the progress of the current animation to a specific value between 0 and 1.
Viewmodels overwrite their animation cycle every frame, for prediction/interpolation purposes. Issue Tracker: 3038
This is used internally - although you're able to use it you probably shouldn't.
This is called internally by the Entity:NetworkVar system, you can use this in cases where using NetworkVar is not possible.
Sets the specified angle on the entity's datatable.
This is used internally - although you're able to use it you probably shouldn't.
This is called internally by the Entity:NetworkVar system, you can use this in cases where using NetworkVar is not possible.
Sets the specified bool on the entity's datatable.
This is used internally - although you're able to use it you probably shouldn't.
This is called internally by the Entity:NetworkVar system, you can use this in cases where using NetworkVar is not possible.
Sets the specified entity on this entity's datatable.
This is used internally - although you're able to use it you probably shouldn't.
This is called internally by the Entity:NetworkVar system, you can use this in cases where using NetworkVar is not possible.
Sets the specified float on the entity's datatable.
This is used internally - although you're able to use it you probably shouldn't.
This is called internally by the Entity:NetworkVar system, you can use this in cases where using NetworkVar is not possible.
Sets the specified integer on the entity's datatable.
This is used internally - although you're able to use it you probably shouldn't.
This is called internally by the Entity:NetworkVar system, you can use this in cases where using NetworkVar is not possible.
Sets the specified string on the entity's datatable.
The length of these strings are capped at 512 characters.
This is used internally - although you're able to use it you probably shouldn't.
This is called internally by the Entity:NetworkVar system, you can use this in cases where using NetworkVar is not possible.
Sets the specified vector on the entity's datatable.
Entity:SetElasticity( number elasticity )
Sets the elasticity of this entity, used by some flying entities such as the Helicopter NPC to determine how much it should bounce around when colliding.
Allows you to set the Start or End entity attachment for the rope.
Entity:SetEyeTarget( Vector pos )
Sets the position an entity's eyes look toward. This works as an override for default behavior. Set to 0,0,0 to disable the override.
Entity:SetFlexScale( number scale )
Sets the scale of all the flexes of this entity. See Entity:SetFlexWeight.
Sets the weight/value of given flex controller.
Only 96 flex controllers can be set! Flex controllers on models with higher amounts will not be accessible.
Entity:SetFriction( number friction )
Sets friction multiplier for this entity when sliding against a surface. Entities default to 1 (100%) and can be higher.
This may not affect all entities, but does work for players (the range is 0 to 10), as well as other entities using MOVETYPE_STEP
This only multiplies the friction of the entity, to change the value itself use PhysObj:SetMaterial.
Entity:SetGravity( number multiplier )
Sets the gravity multiplier of the entity.
This may not affect affect all entities, but does affect players, and entities with MOVETYPE_FLYGRAVITY, such as projectiles.
This function is not predicted or networked. Issue Tracker: 3648
Entity:SetGroundEntity( Entity ground )
Sets the ground the entity is standing on.
Sets the health of the entity.
You may want to take Entity:GetMaxHealth into account when calculating what to set health to, in case a gamemode has a different max health than 100.
In some cases, setting health only serverside can cause hitches in movement, for example if something is modifying the player speed based on health.
To solve this issue, it is better to set it shared in a predicted hook.
Entity:SetHitboxSet( number id )
Sets the current Hitbox set for the entity.
Enables or disable the inverse kinematic usage of this entity.
Calling this with false outside of ENTITY:Initialize requires a model change to take effect.
Sets Hammer key values on an entity.
You can look up which entities have what key values on the Valve Developer Community on entity pages.
A list of basic entities can be found here.
Alternatively you can look at the . fgd files shipped with Garry's Mod in the bin/ folder with a text editor to see the key values as they appear in Hammer.
Entity:SetLagCompensated( boolean enable )
This allows the entity to be lag compensated during Player:LagCompensation.
Players are lag compensated by default and there's no need to call this function for them.
It's best to not enable lag compensation on parented entities, as the system does not handle it that well ( they will be moved back but then the entity will lag behind ).
Parented entities move back with the parent if it's lag compensated, so if you are making some kind of armor piece you shouldn't do anything.
As a side note for parented entities, if your entity can be shot at, keep in mind that its collision bounds need to be bigger than the bone's hitbox the entity is parented to, or hull/line traces ( such as the crowbar attack or bullets ) might not hit at all.
This function only works on BaseAnimatingOverlay entites!
This function only works on BaseAnimatingOverlay entites!
Sets the animation cycle/frame of given layer.
This function only works on BaseAnimatingOverlay entities.
Sets the duration of given layer. This internally overrides the Entity:SetLayerPlaybackRate.
This function only works on BaseAnimatingOverlay entities.
Sets whether the layer should loop or not.
This function only works on BaseAnimatingOverlay entites!
Sets the layer playback rate. See also Entity:SetLayerDuration.
This function only works on BaseAnimatingOverlay entities.
Sets the priority of given layer.
This function only works on BaseAnimatingOverlay entites!
Sets the sequence of given layer.
This function only works on BaseAnimatingOverlay entities.
Sets the layer weight. This influences how strongly the animation should be overriding the normal animations of the entity.
This function only works on BaseAnimatingOverlay entities.
Entity:SetLegacyTransform( boolean enabled )
This forces an entity to use the bone transformation behaviour from versions prior to 8 July 2014.
This behaviour affects Entity:EnableMatrix and Entity:SetModelScale and is incorrect, therefore this function be used exclusively as a quick fix for old scripts that rely on it.
Entity:SetLightingOriginEntity( Entity lightOrigin )
Sets the entity to be used as the light origin position for this entity.
Entity:SetLocalAngles( Angle ang )
Sets angles relative to angles of Entity:GetParent
Entity:SetLocalAngularVelocity( Angle angVel )
Sets the entity's angular velocity (rotation speed).
Entity:SetLocalPos( Vector pos )
Sets local position relative to the parented position. This is for use with Entity:SetParent to offset position.
Entity:SetLocalVelocity( Vector velocity )
Sets the entity's local velocity which is their velocity due to movement in the world from forces such as gravity. Does not include velocity from entity-on-entity collision or other world movement.
Same as Entity:SetAbsVelocity, but clamps the given velocity, and is not recommended to be used because of that.
Sets the Level Of Detail model to use with this entity. This may not work for all models if the model doesn't include any LOD sub models.
This function works exactly like the clientside r_lod convar and takes priority over it.
Entity:SetMaterial( string materialName )
Sets the rendering material override of the entity.
To set a Lua material created with CreateMaterial, just prepend a "!" to the material name.
If you wish to override a single material on the model, use Entity:SetSubMaterial instead.
To apply materials to models, that material must have VertexLitGeneric shader. For that reason you cannot apply map textures onto models, map textures use a different material shader - LightmappedGeneric, which can be used on brush entities. The server's value takes priority on the client. Issue Tracker: 3362
Entity:SetMaxHealth( number maxhealth )
Sets the maximum health for entity. Note, that you can still set entity's health above this amount with Entity:SetHealth.
Sets the model of the entity.
This does not update the physics of the entity - see Entity:PhysicsInit.
This silently fails when given an empty string.
Entity:SetModelName( string modelname )
Alter the model name returned by Entity:GetModel. Does not affect the entity's actual model.
Scales the model of the entity, if the entity is a Player or an NPC the hitboxes will be scaled as well.
For some entities, calling Entity:Activate after this will scale the collision bounds and PhysObj as well; be wary as there's no optimization being done internally and highly complex collision models might crash the server.
This is the same system used in TF2 for the Mann Vs Machine robots.
To resize the entity along any axis, use Entity:EnableMatrix instead.
Client-side trace detection seems to mess up if deltaTime is set to anything but zero. A very small decimal can be used instead of zero to solve this issue.
If your old scales are wrong, use Entity:SetLegacyTransform as a quick fix.
If you do not want the physics to be affected by Entity:Activate, you can use Entity:ManipulateBoneScale( 0, Vector( scale, scale, scale ) ) instead. This does not scale procedural bones and disables IK. Issue Tracker: 3502
Entity:SetMoveCollide( number moveCollideType )
Sets the move collide type of the entity. The move collide is the way a physics object reacts to hitting an object - will it bounce, slide?
Entity:SetMoveParent( Entity Parent )
Sets the Movement Parent of an entity to another entity.
Similar to Entity:SetParent, except the object's coordinates are not translated automatically before parenting.
Does nothing on client.
Entity:SetMoveType( number movetype )
Sets the entity's move type. This should be called before initializing the physics object on the entity, unless it will override SetMoveType such as Entity:PhysicsInitBox.
Despite existing on client, it doesn't actually do anything on client.
Entity:SetNetworkAngles( Angle angle )
Alters the entity's perceived serverside angle on the client.
Sets a networked angle value on the entity.
The value can then be accessed with Entity:GetNetworked2Angle both from client and server.
We advise against using this. It may be changed or removed in a future update.
You should be using Entity:SetNW2Angle instead. The value will only be updated clientside if the entity is or enters the clients PVS. use Entity:SetNWAngle insteadRunning this function clientside will only set it for the client it is called on.
The value will only be networked if it isn't the same as the current value and unlike SetNW*
the value will only be networked once and not every 10 seconds.
Sets a networked boolean value on the entity.
The value can then be accessed with Entity:GetNetworked2Bool both from client and server.
We advise against using this. It may be changed or removed in a future update.
You should be using Entity:SetNW2Bool instead. The value will only be updated clientside if the entity is or enters the clients PVS. use Entity:SetNWBool insteadRunning this function clientside will only set it for the client it is called on.
The value will only be networked if it isn't the same as the current value and unlike SetNW*
the value will only be networked once and not every 10 seconds.
Sets a networked entity value on the entity.
The value can then be accessed with Entity:GetNetworked2Entity both from client and server.
We advise against using this. It may be changed or removed in a future update.
You should be using Entity:SetNW2Entity instead. The value will only be updated clientside if the entity is or enters the clients PVS. use Entity:SetNWEntity insteadRunning this function clientside will only set it for the client it is called on.
The value will only be networked if it isn't the same as the current value and unlike SetNW*
the value will only be networked once and not every 10 seconds.
Sets a networked float (number) value on the entity.
The value can then be accessed with Entity:GetNetworked2Float both from client and server.
Unlike Entity:SetNetworked2Int, floats don't have to be whole numbers.
The value will only be updated clientside if the entity is or enters the clients PVS. use Entity:SetNWFloat insteadRunning this function clientside will only set it for the client it is called on.
The value will only be networked if it isn't the same as the current value and unlike SetNW*
the value will only be networked once and not every 10 seconds.
Sets a networked integer (whole number) value on the entity.
The value can then be accessed with Entity:GetNetworked2Int both from client and server.
See Entity:SetNW2Float for numbers that aren't integers.
We advise against using this. It may be changed or removed in a future update.
You should be using Entity:SetNW2Int instead. The value will only be updated clientside if the entity is or enters the clients PVS.
The integer has a 32 bit limit. Use Entity:SetNWInt insteadRunning this function clientside will only set it for the client it is called on.
The value will only be networked if it isn't the same as the current value and unlike SetNW*
the value will only be networked once and not every 10 seconds.
Sets a networked string value on the entity.
The value can then be accessed with Entity:GetNetworked2String both from client and server.
We advise against using this. It may be changed or removed in a future update.
You should be using Entity:SetNW2String instead. The value will only be updated clientside if the entity is or enters the clients PVS. use Entity:SetNWString insteadRunning this function clientside will only set it for the client it is called on.
The value will only be networked if it isn't the same as the current value and unlike SetNW*
the value will only be networked once and not every 10 seconds.
Sets a networked value on the entity.
The value can then be accessed with Entity:GetNetworked2Var both from client and server.
Allowed Types
Angle
Boolean
Entity
Float
Int
String
Vector
We advise against using this. It may be changed or removed in a future update.
You should be using Entity:SetNW2Var instead. Trying to network a type that is not listed above leads to the value not being networked!Running this function clientside will only set it for the client it is called on.
The value will only be networked if it isn't the same as the current value and unlike SetNW*
the value will only ne networked once and not every 10 seconds.
Sets a function to be called when the NW2Var changes. Internally uses GM:EntityNetworkedVarChanged to call the function.
Only one NW2VarProxy can be set per-var
Running this function clientside will only set it for the client it is called on.
Sets a networked vector value on the entity.
The value can then be accessed with Entity:GetNetworked2Vector both from client and server.
We advise against using this. It may be changed or removed in a future update.
You should be using Entity:SetNW2Vector instead. The value will only be updated clientside if the entity is or enters the clients PVS. use Entity:SetNWVector insteadRunning this function clientside will only set it for the client it is called on.
The value will only be networked if it isn't the same as the current value and unlike SetNW*
the value will only be networked once and not every 10 seconds.
We advise against using this. It may be changed or removed in a future update.
You should use Entity:SetNWAngle instead.
Sets a networked angle value at specified index on the entity.
The value then can be accessed with Entity:GetNetworkedAngle both from client and server.
Running this function clientside will only set it clientside for the client it is called on.
We advise against using this. It may be changed or removed in a future update.
You should use Entity:SetNWBool instead.
Sets a networked boolean value at specified index on the entity.
The value then can be accessed with Entity:GetNetworkedBool both from client and server.
Running this function clientside will only set it clientside for the client it is called on.
We advise against using this. It may be changed or removed in a future update.
You should use Entity:SetNWEntity instead.
Sets a networked entity value at specified index on the entity.
The value then can be accessed with Entity:GetNetworkedEntity both from client and server.
Running this function clientside will only set it clientside for the client it is called on.
We advise against using this. It may be changed or removed in a future update.
You should use Entity:SetNWFloat instead.
Sets a networked float value at specified index on the entity.
The value then can be accessed with Entity:GetNetworkedFloat both from client and server.
Seems to be the same as Entity:GetNetworkedInt.
Running this function clientside will only set it clientside for the client it is called on.
We advise against using this. It may be changed or removed in a future update.
You should use Entity:SetNWInt instead.
Sets a networked integer value at specified index on the entity.
The value then can be accessed with Entity:GetNetworkedInt both from client and server.
Running this function clientside will only set it clientside for the client it is called on.
We advise against using this. It may be changed or removed in a future update.
You should be using Entity:SetNWFloat instead.
Sets a networked number at the specified index on the entity.
We advise against using this. It may be changed or removed in a future update.
You should use Entity:SetNWString instead.
Sets a networked string value at specified index on the entity.
The value then can be accessed with Entity:GetNetworkedString both from client and server.
Running this function clientside will only set it clientside for the client it is called on.
Sets a networked value on the entity.
The value can then be accessed with Entity:GetNetworkedVar both from client and server.
Allowed Types
Angle
Boolean
Entity
Float
Int
String
Vector
We advise against using this. It may be changed or removed in a future update. Trying to network a type that is not listed above leads to the value not being networked!
the value will only be updated clientside if the entity is or enters the clients PVS. Running this function clientside will only set it for the client it is called on.
The value will only be networked if it isn't the same as the current value and unlike SetNW*
the value will only be networked once and not every 10 seconds.
We advise against using this. It may be changed or removed in a future update.
You should be using Entity:SetNWVarProxy instead.
Sets callback function to be called when given NWVar changes.
We advise against using this. It may be changed or removed in a future update.
You should use Entity:SetNWVector instead.
Sets a networked vector value at specified index on the entity.
The value then can be accessed with Entity:GetNetworkedVector both from client and server.
Running this function clientside will only set it clientside for the client it is called on.
Entity:SetNetworkOrigin( Vector origin )
Virtually changes entity position for clients. Does the same thing as Entity:SetPos when used serverside.
Entity:SetNextClientThink( number nextthink )
Sets the next time the clientside ENTITY:Think is called.
Sets if the entity's model should render at all.
If set on the server, this entity will no longer network to clients, and for all intents and purposes cease to exist clientside.
Entity:SetNotSolid( boolean IsNotSolid )
Sets whether the entity is solid or not.
Sets a networked angle value on the entity.
The value can then be accessed with Entity:GetNW2Angle both from client and server.
The value will only be updated clientside if the entity is or enters the clients PVS. use Entity:SetNWAngle insteadRunning this function clientside will only set it for the client it is called on.
The value will only be networked if it isn't the same as the current value and unlike SetNW*
the value will only be networked once and not every 10 seconds.
Sets a networked boolean value on the entity.
The value can then be accessed with Entity:GetNW2Bool both from client and server.
You should not use the NW2 System on entities that are based on a Lua Entity or else NW2Vars could get mixed up, updated multiple times or not be set. Issue Tracker: 5455The value will only be updated clientside if the entity is or enters the clients PVS. use Entity:SetNWBool insteadRunning this function clientside will only set it for the client it is called on.
The value will only be networked if it isn't the same as the current value and unlike SetNW*
the value will only be networked once and not every 10 seconds.
Sets a networked entity value on the entity.
The value can then be accessed with Entity:GetNW2Entity both from client and server.
You should not use the NW2 System on entities that are based on a Lua Entity or else NW2Vars could get mixed up, updated multiple times or not be set. Issue Tracker: 5455The value will only be updated clientside if the entity is or enters the clients PVS. use Entity:SetNWEntity insteadRunning this function clientside will only set it for the client it is called on.
The value will only be networked if it isn't the same as the current value and unlike SetNW*
the value will only be networked once and not every 10 seconds.
Sets a networked float (number) value on the entity.
The value can then be accessed with Entity:GetNW2Float both from client and server.
Unlike Entity:SetNW2Int, floats don't have to be whole numbers.
You should not use the NW2 System on entities that are based on a Lua Entity or else NW2Vars could get mixed up, updated multiple times or not be set. Issue Tracker: 5455The value will only be updated clientside if the entity is or enters the clients PVS. use Entity:SetNWFloat insteadRunning this function clientside will only set it for the client it is called on.
The value will only be networked if it isn't the same as the current value and unlike SetNW*
the value will only be networked once and not every 10 seconds.
Sets a networked integer (whole number) value on the entity.
The value can then be accessed with Entity:GetNW2Int both from client and server.
See Entity:SetNW2Float for numbers that aren't integers.
You should not use the NW2 System on entities that are based on a Lua Entity or else NW2Vars could get mixed up, updated multiple times or not be set. Issue Tracker: 5455The value will only be updated clientside if the entity is or enters the clients PVS.
The integer has a 32 bit limit. Use Entity:SetNWInt insteadRunning this function clientside will only set it for the client it is called on.
The value will only be networked if it isn't the same as the current value and unlike SetNW*
the value will only be networked once and not every 10 seconds.
Sets a networked string value on the entity.
The value can then be accessed with Entity:GetNW2String both from client and server.
You should not use the NW2 System on entities that are based on a Lua Entity or else NW2Vars could get mixed up, updated multiple times or not be set. Issue Tracker: 5455The value will only be updated clientside if the entity is or enters the clients PVS. use Entity:SetNWString insteadRunning this function clientside will only set it for the client it is called on.
The value will only be networked if it isn't the same as the current value and unlike SetNW*
the value will only be networked once and not every 10 seconds.
Sets a networked value on the entity.
The value can then be accessed with Entity:GetNW2Var both from client and server.
Allowed Types
Angle
Boolean
Entity
Float
Int
String
Vector
Trying to network a type that is not listed above leads to the value not being networked!
the value will only be updated clientside if the entity is or enters the clients PVS. You should not use the NW2 System on entities that are based on a Lua Entity or else NW2Vars could get mixed up, updated multiple times or not be set. Issue Tracker: 5455Running this function clientside will only set it for the client it is called on.
The value will only be networked if it isn't the same as the current value and unlike SetNW*
the value will only be networked once and not every 10 seconds.
Sets a function to be called when the NW2Var changes. Internally uses GM:EntityNetworkedVarChanged to call the function.
Alias of Entity:SetNetworked2VarProxy
You should not use the NW2 System on entities that are based on a Lua Entity, or else this will be called multiple times and the NW2Var could get mixed up with other ones. Issue Tracker: 5455Only one NW2VarProxy can be set per-var
Running this function will only set it for the realm it is called on.
Sets a networked vector value on the entity.
The value can then be accessed with Entity:GetNW2Vector both from client and server.
You should not use the NW2 System on entities that are based on a Lua Entity or else NW2Vars could get mixed up, updated multiple times or not be set. Issue Tracker: 5455The value will only be updated clientside if the entity is or enters the clients PVS. use Entity:SetNWVector insteadRunning this function clientside will only set it for the client it is called on.
The value will only be networked if it isn't the same as the current value and unlike SetNW*
the value will only be networked once and not every 10 seconds.
Sets a networked angle value on the entity.
The value can then be accessed with Entity:GetNWAngle both from client and server.
There's a 4095 slots Network limit. If you need more, consider using the net library or Entity:SetNW2Angle. You should also consider the fact that you have way too many variables. You can learn more about this limit here: Networking_UsageRunning this function clientside will only set it for the client it is called on.
Sets a networked boolean value on the entity.
The value can then be accessed with Entity:GetNWBool both from client and server.
There's a 4096 slots Network limit. If you need more, consider using the net library or Entity:SetNW2Bool. You should also consider the fact that you have way too many variables. You can learn more about this limit here: Networking_UsageRunning this function clientside will only set it for the client it is called on.
Sets a networked entity value on the entity.
The value can then be accessed with Entity:GetNWEntity both from client and server.
There's a 4096 slots Network limit. If you need more, consider using the net library or Entity:SetNW2Entity. You should also consider the fact that you have way too many variables. You can learn more about this limit here: Networking_UsageRunning this function clientside will only set it for the client it is called on.
Sets a networked float (number) value on the entity.
The value can then be accessed with Entity:GetNWFloat both from client and server.
Unlike Entity:SetNWInt, floats don't have to be whole numbers.
There's a 4095 slots Network limit. If you need more, consider using the net library or Entity:SetNW2Float. You should also consider the fact that you have way too many variables. You can learn more about this limit here: Networking_UsageRunning this function clientside will only set it for the client it is called on.
Sets a networked integer (whole number) value on the entity.
The value can then be accessed with Entity:GetNWInt both from client and server.
See Entity:SetNWFloat for numbers that aren't integers.
There's a 4095 slots Network limit. If you need more, consider using the net library or Entity:SetNW2Int. You should also consider the fact that you have way too many variables. You can learn more about this limit here: Networking_UsageRunning this function clientside will only set it for the client it is called on. This function will not round decimal values as it actually networks a float internally. Issue Tracker: 3374
Sets a networked string value on the entity.
The value can then be accessed with Entity:GetNWString both from client and server.
There's a 4095 slots Network limit. If you need more, consider using the net library or Entity:SetNW2String. You should also consider the fact that you have way too many variables. You can learn more about this limit here: Networking_UsageRunning this function clientside will only set it for the client it is called on.
Only one NWVarProxy can be set per-var
Running this function will only set it for the realm it is called on.
Sets a function to be called when the NWVar changes.
Sets a networked vector value on the entity.
The value can then be accessed with Entity:GetNWVector both from client and server.
There's a 4095 slots Network limit. If you need more, consider using the net library or Entity:SetNW2Vector. You should also consider the fact that you have way too many variables. You can learn more about this limit here: Networking_UsageRunning this function clientside will only set it for the client it is called on.
Sets the owner of this entity, disabling all physics interaction with it.
This function is generally used to disable physics interactions on projectiles being fired by their owner, but can also be used for normal ownership in case physics interactions are not involved at all. The Gravity gun will be able to pick up the entity even if the owner can't collide with it, the Physics gun however will not.
Sets the parent of this entity, making it move with its parent. This will make the child entity non solid, nothing can interact with them, including traces.
This does not work on the world. This can cause undefined physics behavior when used on entities that don't support parenting. See the Valve developer wiki for more information.
Entity:SetParentPhysNum( number bone )
Sets the parent of an entity to another entity with the given physics bone number. Similar to Entity:SetParent, except it is parented to a physbone. This function is useful mainly for ragdolls.
Despite this function being available server side, it doesn't actually do anything server side.
Entity:SetPersistent( boolean persist )
Sets whether or not the given entity is persistent. A persistent entity will be saved on server shutdown and loaded back when the server starts up. Additionally, by default persistent entities cannot be grabbed with the physgun and tools cannot be used on them.
In sandbox, this can be set on an entity by opening the context menu, right clicking the entity, and choosing "Make Persistent".
Persistence can only be enabled with the sbox_persist convar, which works as an identifier for the current set of persistent entities. An empty identifier (which is the default value) disables this feature.
When called on a constraint entity, sets the two physics objects to be constrained.
Usage is not recommended as the Constraint library provides easier ways to deal with constraints.
Sets the player who gets credit if this entity kills something with physics damage within the time limit.
This can only be called on props, "anim" type SENTs and vehicles.
Entity:SetPlaybackRate( number fSpeed )
Allows you to set how fast an entity's animation will play, with 1. 0 being the default speed.
Moves the entity to the specified position.
Some entities, such as ragdolls, will continually reset their position. Consider using PhysObj:SetPos on every physics object to move ragdolls.
If the new position doesn't take effect right away, you can use Entity:SetupBones to force it to do so. This issue is especially common when trying to render the same entity twice or more in a single frame at different positions. Entities with Entity:GetSolid of SOLID_BBOX will have their angles reset!This will fail inside of predicted functions called during player movement processing. This includes WEAPON:PrimaryAttack and WEAPON:Think. Issue Tracker: 2447
Sets the specified pose parameter to the specified value.
You should call Entity:InvalidateBoneCache after calling this function.
Avoid calling this in draw hooks, especially when animating things, as it might cause visual artifacts.
Entity:SetPredictable( boolean setPredictable )
Sets whether an entity should be predictable or not.
When an entity is set as predictable, its DT vars can be changed during predicted hooks. This is useful for entities which can be controlled by player input.
Any datatable value that mismatches from the server will be overridden and a prediction error will be spewed.
Weapons are predictable by default, and the drive system uses this function to make the controlled prop predictable as well.
Visit for a list of all predicted hooks, and the Prediction page.
For further technical information on the subject, visit valve's wiki.
This function resets the datatable variables everytime it's called, it should ideally be called when a player starts using the entity and when he stopsEntities set as predictable with this function will be unmarked when the user lags and receives a full packet update, to handle such case visit GM:NotifyShouldTransmit
Prevents the server from sending any further information about the entity to a player.
You must also call this function on all entity's children. See Entity:GetChildren.
issue tracker
Entity:SetFlexScale and other flex/bone manipulation functions will create a child entity.
Sets the bone angles. This is used alongside Kinect in Entity:SetRagdollBuildFunction, for more info see ragdoll_motion entity.
Entity:SetRagdollBuildFunction( function builder )
Sets the function to build the ragdoll. This is used alongside Kinect, for more info see ragdoll_motion entity in the game files.
Sets the bone position. This is used alongside Kinect in Entity:SetRagdollBuildFunction, for more info see ragdoll_motion entity.
Entity:SetRenderAngles( Angle newAngles = nil )
Sets the render angle override for the Entity.
Sets the render bounds for the entity. For world space coordinates see Entity:SetRenderBoundsWS.
Sets the render bounds for the entity in world space coordinates. For relative coordinates see Entity:SetRenderBounds.
Used to specify a plane, past which an object will be visually clipped.
Entity:SetRenderClipPlaneEnabled( boolean enabled )
Enables the use of clipping planes to "cut" objects.
Entity:SetRenderFX( number renderFX )
Sets entity's render FX.
Entity:SetRenderMode( number renderMode )
Sets the render mode of the entity.
Entity:SetRenderOrigin( Vector newOrigin = nil )
Set the render origin override, a position where the Entity will be rendered at.
Sets a save value for an entity. You can see a full list of an entity's save values by creating it and printing Entity:GetSaveTable().
See Entity:GetInternalVariable for the opposite of this function.
Entity:SetSequence( number sequenceId )
Sets the entity's model sequence.
If the specified sequence is already active, the animation will not be restarted. See Entity:ResetSequence for a function that restarts the animation even if it is already playing.
In some cases you want to run Entity:ResetSequenceInfo to make this function run.
This will not work properly if called directly after calling Entity:SetModel. Consider waiting until the next Tick.
Will not work on players due to the animations being reset every frame by the base gamemode animation system. See GM:CalcMainActivity.
For custom scripted entities you will want to apply example from ENTITY:Think to make animations work.
Entity:SetShouldPlayPickupSound( boolean playsound = false )
Sets whether or not the entity should make a physics contact sound when it's been picked up by a player.
Entity:SetShouldServerRagdoll( boolean serverragdoll )
Sets if entity should create a server ragdoll on death or a client one.
Player ragdolls created with this enabled will have an owner set, see Entity:SetOwner for more information on what effects this has.
This is reset for players when they respawn (Entity:Spawn).
Entity:SetSolidFlags( number flags )
Sets solid flag(s) for the entity.
This overrides any other flags the entity might have had. See Entity:AddSolidFlags for adding flags.
Entity:SetSpawnEffect( boolean spawnEffect )
Sets whether the entity should use a spawn effect when it is created on the client.
See Entity:GetSpawnEffect for more information on how the effect is applied.
This function will only have an effect when the entity spawns. After that it will do nothing even is set to true.
Overrides a single material on the model of this entity.
To set a Lua material created with CreateMaterial, just prepend a ! to the material name.
The server's value takes priority on the client. Issue Tracker: 3362
Sets the axis-aligned bounding box (AABB) for an entity's hitbox detection.
See also Entity:SetSurroundingBoundsType (mutually exclusive).
Entity:SetSurroundingBoundsType( number bounds )
Automatically sets the axis-aligned bounding box (AABB) for an entity's hitbox detection.
See also Entity:SetSurroundingBounds (mutually exclusive).
This is used internally - although you're able to use it you probably shouldn't.
Changes the table that can be accessed by indexing an entity. Each entity starts with its own table by default.
Entity:SetTransmitWithParent( boolean onoff )
When this flag is set the entity will only transmit to the player when its parent is transmitted. This is useful for things like viewmodel attachments since without this flag they will transmit to everyone (and cause the viewmodels to transmit to everyone too).
In the case of scripted entities, this will override ENTITY:UpdateTransmitState
Entity:SetTrigger( boolean maketrigger )
Marks the entity as a trigger, so it will generate ENTITY:StartTouch, ENTITY:Touch and ENTITY:EndTouch callbacks.
Internally this is stored as FSOLID_TRIGGER flag.
Entity:SetUnFreezable( boolean freezable = false )
Sets whether an entity can be unfrozen, meaning that it cannot be unfrozen using the physgun.
Entity:SetupBones()
Forces the entity to reconfigure its bones. You might need to call this after changing your model's scales or when manually drawing the entity multiple times at different positions.
This calls the BuildBonePositions callback added via Entity:AddCallback, so avoid calling this function inside it to prevent an infinite loop.
Entity:SetupPhonemeMappings( string fileRoot )
Initializes the class names of an entity's phoneme mappings (mouth movement data). This is called by default with argument "phonemes" when a flex-based entity (such as an NPC) is created.
TF2 phonemes can be accessed by using a path such as "player/scout/phonemes/phonemes" , check TF2's "tf2_misc_dir. vpk" with GCFScape for other paths, however it seems that TF2 sounds don't contain phoneme definitions anymore after being converted to mp3 and only rely on VCD animations, this needs to be further investigated
Entity:SetUseType( number useType )
Sets the use type of an entity, affecting how often ENTITY:Use will be called for Lua entities.
Allows to quickly set variable to entity's Entity:GetTable.
This will not network the variable to client(s). You want Entity:SetNWString and similar functions for that
Entity:SetVelocity( Vector velocity )
Sets the entity's velocity. For entities with physics, consider using PhysObj:SetVelocity on the PhysObj of the entity.
Actually binds to CBaseEntity::SetBaseVelocity() which sets the entity's velocity due to forces applied by other entities. If applied to a player, this will actually ADD velocity, not set it. (due to how movement code handles base velocity)
Sets the model and associated weapon to this viewmodel entity.
This is used internally when the player switches weapon.
View models are not drawn without a weapons associated to them. This will silently fail if the entity is not a viewmodel.
Moves the model instance from the source entity to this entity. This can be used to transfer decals that have been applied on one entity to another.
Both entities must have the same model.
Entity:Spawn()
Initializes the entity and starts its networking. If called on a player, it will respawn them.
This calls ENTITY:Initialize on Lua-defined entities.
Starts a "looping" sound. As with any other sound playing methods, this function expects the sound file to be looping itself and will not automatically loop a non looping sound file as one might expect.
This function is almost identical to CreateSound, with the exception of the sound being created in the STATIC channel and with normal attenuation.
See also Entity:StopLoopingSound
Entity:StartMotionController()
Starts a motion controller in the physics engine tied to this entity's PhysObj, which enables the use of ENTITY:PhysicsSimulate.
The motion controller can later be destroyed via Entity:StopMotionController.
Motion controllers are used internally to control other Entities' PhysObjects, such as the Gravity Gun, +use pickup and the Physics Gun.
This function should be called every time you recreate the Entity's PhysObj. Or alternatively you should call Entity:AddToMotionController on the new PhysObj.
Also see Entity:AddToMotionController and Entity:RemoveFromMotionController.
Only works on a scripted Entity of anim type.
Entity:StopAndDestroyParticles()
Stops all particle effects parented to the entity and immediately destroys them.
Entity:StopLoopingSound( number id )
Stops a sound created by Entity:StartLoopingSound.
Entity:StopMotionController()
Stops the motion controller created with Entity:StartMotionController.
Entity:StopParticleEmission()
Stops all particle effects parented to the entity.
This is ran automatically on every client by Entity:StopParticles if called on the server.
Entity:StopParticles()
Stops any attached to the entity . pcf particles using ParticleEffectAttach or ParticleEffect.
On client, this is the same as Entity:StopParticleEmission. ( and you should use StopParticleEmission instead )
On server, this is the same as running Entity:StopParticleEmission on every client.
Entity:StopParticlesNamed( string name )
Stops all particle effects parented to the entity with given name.
Stops all particle effects parented to the entity with given name on given attachment.
Stops emitting the given sound from the entity, especially useful for looping sounds.
Applies the specified amount of damage to the entity with DMG_GENERIC flag.
Calling this function on the victim entity in ENTITY:OnTakeDamage can cause infinite loops. This function does not seem to do any damage if you apply it to a player who is driving a prop_vehicle_jeep or prop_vehicle_jeep_old vehicle. You need to call it on the vehicle instead.
Entity:TakeDamageInfo( CTakeDamageInfo damageInfo )
Applies the damage specified by the damage info to the entity.
Calling this function on the victim entity in ENTITY:OnTakeDamage can cause infinite loops. This function does not seem to do any damage if you apply it to a player who is driving a prop_vehicle_jeep or prop_vehicle_jeep_old vehicle. You need to call it on the vehicle instead. This function does not apply damage to func_breakable_surf entities correctly. To do this, you will need to use Entity:DispatchTraceAttack instead.
Entity:TakePhysicsDamage( CTakeDamageInfo dmginfo )
Applies forces to our physics object in response to damage.
Check if the given position or entity is within this entity's PVS(Potential Visibility Set).
See also Entity:IsDormant.
The function won't take in to account AddOriginToPVS and the like.
Returns the ID of a PhysObj attached to the given bone.
See Entity:TranslatePhysBoneToBone for reverse function.
Returns the boneID of the bone the given PhysObj is attached to.
See Entity:TranslateBoneToPhysBone for reverse function.
Entity:UpdateBoneFollowers()
Updates positions of bone followers created by Entity:CreateBoneFollowers.
This should be called every tick.
This function only works on anim, nextbot and ai type entities.
Entity:UpdateShadow()
Marks the render-to-texture (RTT) shadow of this entity as dirty, as well as any potential projected texture shadows related to this entity, so they will be updated as soon as possible.
Simulates a +use action on an entity.
Entity:UseClientSideAnimation()
Does nothing on server.
Animations will be handled purely clientside instead of a fixed animtime, enabling interpolation. This does not affect layers and gestures.
Enables or disables trigger bounds.
This will give the entity a "trigger box" that extends around its bounding box by boundSize units in X/Y and (boundSize / 2) in +Z (-Z remains the same).
The trigger box is world aligned and will work regardless of the object's solidity and collision group.
Valve use trigger boxes for all pickup items. Their bloat size is 24, a surprisingly large figure.
The trigger boxes can be made visible as a light blue box by using the ent_bbox console command while looking at the entity. Alternatively a classname or entity index can be used as the first argument.
This requires developer to be set to 1.
number Entity:ViewModelIndex()
Returns the index of this view model, it can be used to identify which one of the player's view models this entity is.
Returns whether the target/given entity is visible from the this entity.
This is meant to be used only with NPCs.
Differences from a simple trace include:
If target has FL_NOTARGET, returns false
If ai_ignoreplayers is turned on and target is a player, returns false
Reacts to ai_LOS_mode:
If 1, does a simple trace with COLLISION_GROUP_NONE and MASK_BLOCKLOS
If not, does a trace with MASK_BLOCKLOS_AND_NPCS (- CONTENTS_BLOCKLOS is target is player) and a custom LOS filter (CTraceFilterLOS)
Returns true if hits a vehicle the target is driving
Returns true if supplied vector is visible from the entity's line of sight.
This is achieved similarly to a trace.
number Entity:WaterLevel()
Returns an integer that represents how deep in water the entity is.
This function will currently work on players only due to the way it is implemented in the engine. If you need to check interaction with water for regular entities you better use util. PointContents.
0 - The entity isn't in water.
1 - Slightly submerged (at least to the feet).
2 - The majority of the entity is submerged (at least to the waist).
3 - Completely submerged.
Sets the activity of the entity's active weapon.
This does nothing on the client. Only works for CBaseCombatCharacter entities, which includes players and NPCs.
Calls and returns WEAPON:TranslateActivity on the weapon the entity ( player or NPC ) carries.
Despite existing on client, it doesn't actually do anything on client.
Returns two vectors representing the minimum and maximum extent of the entity's axis-aligned bounding box (which is calculated from entity's collision bounds.
Vector Entity:WorldSpaceCenter()
Returns the center of the entity according to its collision model.
Converts a worldspace vector into a vector local to an entity
Converts world angles to local angles ( local to the entity )
This site is a community mirror of the official Garry's Mod wiki.. This site is not maintained by Facepunch Studios.
Page content is automatically updated twice a day. Edits and history are not available.
Last Parsed: Loading...