Garry's Mod Wiki

Entity

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.
number Entity:AddCallback( string hook, function func )
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.
Entity:AddEFlags( number flag )
Adds engine flags.
Entity:AddFlags( number flag )
Adds flags to the entity.
number Entity:AddGesture( number activity, boolean autokill = true )
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!
number Entity:AddGestureSequence( number sequence, boolean autokill = true )
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!
number Entity:AddLayeredSequence( number sequence, number priority )
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
Angle Entity:AlignAngles( Angle from, Angle to )
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).
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 )
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.
Entity:Blocked( Entity entity )
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.
Vector Entity:BodyTarget( Vector origin, boolean noisy = false )
Returns a centered vector of this entity, NPCs use this internally to aim at their targets. This only works on players and NPCs.
boolean Entity:BoneHasFlag( number boneID, number flag )
Returns whether the entity's bone has the flag or not.
number Entity:BoneLength( number boneID )
Returns the length between given bone's position and the position of given bone's parent.
Returns the distance between the center of the bounding box and the furthest bounding box corner.
Entity:CallDTVarProxies( string Type, number index, any new value )
Calls all Entity:NetworkVarNotify functions with the given new value, but doesn't change the real value.
Entity:CallOnRemove( string identifier, function removeFunc, ... )
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.
Resets all pose parameters such as aim_yaw, aim_pitch and rotation.
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.
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.
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:Dissolve( number type = 0, number magnitude = 0, Vector origin = nil )
Dissolves the entity.
Entity:DontDeleteOnRemove( Entity entityToUnremove )
This removes the argument entity from an ent's list of entities to 'delete on remove' Also see Entity:DeleteOnRemove
Entity:DrawModel( number flags = STUDIO_RENDER )
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.
Entity:DTVar( string Type, number ID, string Name )
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" if the sound file contains lipsync data. See this page for more information. 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.
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.
Entity:EnableMatrix( string matrixType, VMatrix matrix )
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
number Entity:EntIndex()
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.
Angle Entity:EyeAngles()
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
Vector Entity:EyePos()
Returns the position of an Player/NPC's view.
Searches the Entity's model for a Body Group with a given name. Weapons will return results from their viewmodels.
number Entity:FindTransitionSequence( number currentSequence, number goalSequence )
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.
Entity:FireBullets( table bulletInfo, boolean suppressHostEvents = false )
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.
Entity:FollowBone( Entity parent = NULL, number boneid )
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, if it is being held by a player's Gravity Gun, Physics Gun or +use pickup. See also Player:DropObject.
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.
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.
Angle Entity:GetAngles()
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
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
table Entity:GetAnimInfo( number animIndex )
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
Returns the last time the entity had an animation update. Returns 0 if the entity doesn't animate.
Returns the amount of time since last animation. Works only on CBaseAnimating entities.
table Entity:GetAttachment( number attachmentId )
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
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
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.
Returns the blood color of this entity. This can be set with Entity:SetBloodColor.
number Entity:GetBodygroup( number bodyGroupId )
Returns the Sub Model ID for the currently active Sub Model of the Body Group corresponding to the given Body Group ID. Weapons will return results from their viewmodels.
number Entity:GetBodygroupCount( number bodyGroupId )
Returns the number of Sub Models in the Body Group corresponding to a given Body Group ID of the Entity's model. Weapons will return results from their viewmodels.
string Entity:GetBodygroupName( number bodyGroupId )
Retrieves the name of the Body Group corresponding to a given Body Group ID on the Entity's model. Weapons will return results from their viewmodels.
Returns a list of information about each Body Group present on the Entity's model. Weapons will return results from their viewmodels.
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.
Returns the amount of bones in the entity. Will return 0 for ClientsideModel or undrawn entities until Entity:SetupBones is called on the entity.
VMatrix Entity:GetBoneMatrix( number boneID )
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
string Entity:GetBoneName( number index )
Returns name of given bone id.
number Entity:GetBoneParent( number bone )
Returns parent bone of given bone. Will return -1 for ClientsideModel until Entity:SetupBones is called on the entity.
Vector, Angle Entity:GetBonePosition( number boneIndex )
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.
Returns the amount of planes of non-nodraw brush model surfaces of the entity's model.
Returns a table of brushes surfaces for brush model entities.
table Entity:GetCallbacks( string hook )
Returns the specified hook callbacks for this entity added with Entity:AddCallback The callbacks can then be removed with Entity:RemoveCallback.
table Entity:GetChildBones( number boneid )
Returns ids of child bones of given bone.
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.
string Entity:GetClass()
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
Returns the entity's collision group
table Entity:GetColor()
Returns the color the entity is set to.
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.
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.
Returns the time the entity was created on, relative to CurTime.
Gets the creator of the SENT.
Returns whether this entity uses custom collision check set by Entity:SetCustomCollisionCheck.
number Entity:GetCycle()
Returns the frame of the currently played sequence. This will be a number between 0 and 1 as a representation of sequence progress.
Angle Entity:GetDTAngle( number key )
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.
boolean Entity:GetDTBool( number key )
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.
Entity Entity:GetDTEntity( number key )
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.
number Entity:GetDTFloat( number key )
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.
number Entity:GetDTInt( number key )
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.
string Entity:GetDTString( number key )
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.
Vector Entity:GetDTVector( number key )
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.
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
Returns a bit flag of all engine effect flags of the entity.
number Entity:GetEFlags()
Returns a bit flag of all engine flags of the entity.
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.
number Entity:GetFlags()
Returns all flags of given entity.
Returns acceptable value range for the flex.
Returns the ID of the flex based on the beginning or the entire name.
Returns flex name.
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.
Returns the flex scale of the entity.
Returns flex controller type or "category". Used internally by Faceposer to categorize flex controllers.
number Entity:GetFlexWeight( number flex )
Returns current weight ( value ) of given flex controller. Please see Entity:SetFlexWeight regarding limitations.
Returns the forward vector of the entity, as a normalized direction vector
Returns the friction modifier for this entity. Entities default to 1 (100%) and can be higher.
Gets the gravity multiplier of the entity.
Returns the object the entity is standing on.
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.
number Entity:GetHitBoxBone( number hitbox, number hboxset )
Gets the bone the hit box is attached to.
Vector, Vector Entity:GetHitBoxBounds( number hitbox, number set )
Gets the bounds (min and max corners) of a hit box.
Gets how many hit boxes are in a given hit box set.
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
number Entity:GetHitBoxHitGroup( number hitbox, number hitboxset )
Gets the hit group of a given hitbox in a given hitbox set.
Returns entity's current hit box set
Returns the amount of hitbox sets in the entity.
any Entity:GetInternalVariable( string variableName )
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.
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
number Entity:GetLayerCycle( number layerID )
Returns the animation cycle/frame for given layer. This function only works on BaseAnimatingOverlay entities.
number Entity:GetLayerDuration( number layerID )
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.
number Entity:GetLayerSequence( number layerID )
Returns the sequence id of given layer. This function only works on BaseAnimatingOverlay entities.
number Entity:GetLayerWeight( number layerID )
Returns the current weight of the layer. See Entity:SetLayerWeight for more information. This function only works on BaseAnimatingOverlay entities.
Returns the entity that is being used as the light origin position for this entity.
Returns the rotation of the entity relative to its parent entity.
Returns the non-VPhysics angular velocity of the entity relative to its parent entity.
Returns entity's position relative to it's Entity:GetParent. See Entity:GetPos for the absolute position.
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 )
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
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.
Returns the surface material of this entity.
Returns the max health that the entity was given. It can be set via Entity:SetMaxHealth.
string Entity:GetModel()
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. This also affects certain models that are edited by 3rd party programs after being compiled.
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.
Returns the contents of the entity's current model.
Gets the physics bone count of the entity's model. This is only applicable to anim type Scripted Entities with ragdoll models.
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).
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.
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?
Returns the movement parent of this entity. See Entity:SetMoveParent for more info.
Returns the entity's movetype
string Entity:GetName()
Returns the map/hammer targetname of this entity.
Gets networked angles for entity.
any Entity:GetNetworked2Angle( string key, any fallback = Angle( 0, 0, 0 ) )
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.
any Entity:GetNetworked2Bool( string key, any fallback = false )
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.
any Entity:GetNetworked2Entity( string key, any fallback = NULL )
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.
any Entity:GetNetworked2Float( string key, any fallback = 0 )
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.
any Entity:GetNetworked2Int( string key, any fallback = 0 )
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
any Entity:GetNetworked2String( string key, any fallback )
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.
any Entity:GetNetworked2Var( string key, any fallback = nil )
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
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.
any Entity:GetNetworked2Vector( string key, any fallback = Vector( 0, 0, 0 ) )
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.
Angle Entity:GetNetworkedAngle( string key, Angle fallback = Angle( 0, 0, 0 ) )
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.
boolean Entity:GetNetworkedBool( string key, boolean fallback = false )
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.
Entity Entity:GetNetworkedEntity( string key, Entity fallback = NULL )
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.
number Entity:GetNetworkedFloat( string key, number fallback = 0 )
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.
number Entity:GetNetworkedInt( string key, number fallback = 0 )
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.
string Entity:GetNetworkedString( string key, string fallback = "" )
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.
any Entity:GetNetworkedVar( string key, any fallback = nil )
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.
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.
Vector Entity:GetNetworkedVector( string key, Vector fallback = Vector( 0, 0, 0 ) )
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.
Gets networked origin for entity.
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 )
Returns the number of Body Groups that the Entity's model contains. Weapons will return results from their viewmodels.
Returns the number of pose parameters this entity has.
any Entity:GetNW2Angle( string key, any fallback = Angle( 0, 0, 0 ) )
Retrieves a networked angle value at specified index on the entity that is set by Entity:SetNW2Angle.
any Entity:GetNW2Bool( string key, any fallback = false )
Retrieves a networked boolean value at specified index on the entity that is set by Entity:SetNW2Bool.
any Entity:GetNW2Entity( string key, any fallback = NULL )
Retrieves a networked entity value at specified index on the entity that is set by Entity:SetNW2Entity.
any Entity:GetNW2Float( string key, any fallback = 0 )
Retrieves a networked float value at specified index on the entity that is set by Entity:SetNW2Float.
any Entity:GetNW2Int( string key, any fallback = 0 )
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
any Entity:GetNW2String( string key, any fallback )
Retrieves a networked string value at specified index on the entity that is set by Entity:SetNW2String.
any Entity:GetNW2Var( string key, any fallback = nil )
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.
Returns all the NW2 variables in an entity. This function will return keys with empty tables if the NW2Var is nil. Issue Tracker: 5396
any Entity:GetNW2Vector( string key, any fallback = Vector( 0, 0, 0 ) )
Retrieves a networked vector value at specified index on the entity that is set by Entity:SetNW2Vector.
any Entity:GetNWAngle( string key, any fallback = Angle( 0, 0, 0 ) )
Retrieves a networked angle value at specified index on the entity that is set by Entity:SetNWAngle.
any Entity:GetNWBool( string key, any fallback = false )
Retrieves a networked boolean value at specified index on the entity that is set by Entity:SetNWBool.
any Entity:GetNWEntity( string key, any fallback = NULL )
Retrieves a networked entity value at specified index on the entity that is set by Entity:SetNWEntity.
any Entity:GetNWFloat( string key, any fallback = 0 )
Retrieves a networked float value at specified index on the entity that is set by Entity:SetNWFloat.
any Entity:GetNWInt( string key, any fallback = 0 )
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
any Entity:GetNWString( string key, any fallback )
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
Returns all the networked variables in an entity.
any Entity:GetNWVector( string key, any fallback = Vector( 0, 0, 0 ) )
Retrieves a networked vector value at specified index on the entity that is set by Entity:SetNWVector.
Entity Entity:GetOwner()
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.
Entity Entity:GetParent()
Returns the parent entity of this entity.
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.
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.
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.
Returns whether the entity is persistent or not. See Entity:SetPersistent for more information on persistence.
Player Entity:GetPhysicsAttacker( number timeLimit = 1 )
Returns player who is claiming kills of physics damage the entity deals.
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.
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.
Returns the playback rate of the main sequence on this entity, with 1. 0 being the default speed.
Vector Entity:GetPos()
Gets the position of given entity in the world. See Entity:GetLocalPos for the position relative to the entity's Entity:GetParent.
Returns the pose parameter value
Returns name of given pose parameter
Returns pose parameter range
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 and ai type entities. For rest use GM:GetPreferredCarryAngles.
Returns the entity which the ragdoll came from. The opposite of Player:GetRagdollEntity.
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!
Returns current render FX of the entity.
Returns the render group of the entity.
Returns the render mode of the entity.
Returns the entity's render origin, set by Entity:SetRenderOrigin in a drawing hook.
Vector Entity:GetRight()
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.
table Entity:GetSaveTable( boolean showAll )
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.
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.
Returns the amount of sequences ( animations ) the entity's model has.
number Entity:GetSequenceGroundSpeed( number sequenceId )
Returns the ground speed of the entity's sequence.
table Entity:GetSequenceInfo( number sequenceId )
Returns a table of information about an entity's sequence.
Returns a list of all sequences ( animations ) the model has.
number Entity:GetSequenceMoveDist( number sequenceId )
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.
string Entity:GetSequenceName( number index )
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.
Vector Entity:GetSequenceVelocity( number sequenceId, number cycle )
Returns an entity's sequence velocity at given animation frame.
Checks if the entity plays a sound when picked up by a player.
Returns if entity should create a server ragdoll on death or a client one.
number Entity:GetSkin()
Returns the skin index of the current skin.
number Entity:GetSolid()
Returns solid type of an entity.
Returns solid flag(s) of an entity.
Returns if we should show a spawn effect on spawn on this entity.
Returns the bitwise spawn flags used by the entity. These can be set by Entity:SetKeyValue.
string Entity:GetSubMaterial( number index )
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
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.
table Entity:GetTable()
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
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
Returns true if the TransmitWithParent flag is set or not.
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.
Vector Entity:GetUp()
Returns the upward vector of the entity, as a normalized direction vector
any Entity:GetVar( any key, any default = nil )
Retrieves a value from entity's Entity:GetTable. Set by Entity:SetVar.
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
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.
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
Entity:GibBreakClient( Vector force, table clr = nil )
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.
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
Returns whether or not the the entity has had flex manipulations performed with Entity:SetFlexWeight or Entity:SetFlexScale.
boolean Entity:HasSpawnFlags( number spawnFlags )
Returns whether this entity has the specified spawnflags bits set.
Vector Entity:HeadTarget( Vector origin )
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.
number Entity:Health()
Returns the health of the entity.
Entity:Ignite( number length, number radius = 0 )
Sets the entity on fire. See also Entity:Extinguish.
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.
Entity:Input( string input, Entity activator = nil, Entity caller = nil, any param = nil )
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.
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.
Resets the entity's bone cache values in order to prepare for a model change. This should be called after calling Entity:SetPoseParameter.
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
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).
boolean Entity:IsEffectActive( number effect )
Returns whether an entity has engine effect applied or not.
boolean Entity:IsEFlagSet( number flag )
Checks if given flag is set or not.
boolean Entity:IsFlagSet( number flag )
Checks if given flag(s) 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.
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.
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 a NextBot or not.
boolean Entity:IsNPC()
Checks if the entity is an NPC or not. This will return false for NextBots, see Entity:IsNextBot for that.
boolean Entity:IsOnFire()
Returns whether the entity is on fire.
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:IsPlayer()
Checks if the entity is a player or not.
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
boolean Entity:IsPlayingGesture( number activity )
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.
Checks if the entity is a ragdoll.
Checks if the entity is a SENT or a built-in entity.
Returns whether the entity's current sequence is finished or not.
boolean Entity:IsSolid()
Returns if the entity is solid or not. Very useful for determining if the entity is a trigger or not.
boolean Entity:IsValid()
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.
boolean Entity:IsValidLayer( number layerID )
Returns whether the given layer ID is valid and exists on this entity. This function only works on BaseAnimatingOverlay entities.
Checks if the entity is a vehicle or not.
boolean Entity:IsWeapon()
Checks if the entity is a weapon or not.
boolean Entity:IsWidget()
Returns whether the entity is a widget or not. This is used by the "Edit Bones" context menu property.
boolean Entity:IsWorld()
Returns if this entity is the map entity Entity[0] worldspawn.
Vector Entity:LocalToWorld( Vector lpos )
Converts a vector local to an entity into a worldspace vector
Converts a local angle (local to the entity) to a world angle.
number Entity:LookupAttachment( string attachmentName )
Returns the attachment index of the given attachment name.
number Entity:LookupBone( string boneName )
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.
Entity:ManipulateBoneAngles( number boneID, Angle ang, boolean networking = true )
Sets custom bone angles. When used repeatedly serverside, this method is strongly discouraged due to the huge network traffic produced As of update 2024. 10. 29 this has been resolved. However, network traffic is still generated and should be taken into consideration. Issue Tracker: 5148
Entity:ManipulateBoneJiggle( number boneID, number type )
Manipulates the bone's jiggle status. This allows non jiggly bones to become jiggly.
Entity:ManipulateBonePosition( number boneID, Vector pos, boolean networking = true )
Sets custom bone offsets.
Entity:ManipulateBoneScale( number boneID, Vector scale )
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
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.
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
Vector Entity:NearestPoint( Vector position )
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
Entity:NetworkVar( string type, number slot, string name, table extended = nil )
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.
Entity:NetworkVarNotify( string name, function callback )
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.
Entity:NextThink( number timestamp )
Controls when, relative to CurTime, the Entity will next run its Think function. For Scripted Entities, this is the ENTITY:Think function. For engine Entities, this is an internal function whose behavior will depend on the specific Entity type. For a Client-side equivalent, see Entity:SetNextClientThink. This does not work with SWEPs or Nextbots. Issue Tracker: 3269
Vector Entity:OBBCenter()
Returns the center of an entity's bounding box in local space.
Vector Entity:OBBMaxs()
Returns the highest corner of an entity's bounding box as a local vector.
Vector Entity:OBBMins()
Returns the lowest corner of an entity's bounding box as a local vector.
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.
boolean Entity:OnGround()
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 )
boolean Entity:PassesFilter( Entity caller, Entity ent )
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.
boolean Entity:PhysicsFromMesh( table vertices, string surfaceprop = "default", Vector massCenterOveride = nil )
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.
boolean Entity:PhysicsInit( number solidType, Vector massCenterOverride = nil )
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
boolean Entity:PhysicsInitBox( Vector mins, Vector maxs, string surfaceprop = "default", Vector massCenterOverride = nil )
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
boolean Entity:PhysicsInitConvex( table points, string surfaceprop = "default", Vector massCenterOverride = nil )
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
boolean Entity:PhysicsInitMultiConvex( table vertices, string surfaceprop = "default", Vector massCenterOverride = nil )
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
boolean Entity:PhysicsInitSphere( number radius, string physmat = "default" )
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
boolean Entity:PhysicsInitStatic( number solidType )
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
number, Entity Entity:PlayScene( string scene, number delay = 0 )
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.
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.
Sets the function to build the ragdoll. This is used alongside Kinect in Entity:SetRagdollBuildFunction, for more info see ragdoll_motion entity.
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.
Removes and stops all gestures. This function only works on BaseAnimatingOverlay entites!
Entity:RemoveCallback( string hook, number callbackid )
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
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.
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.
Entity:RestartGesture( number activity, boolean addIfMissing = true, boolean autokill = true )
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.
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.
number Entity:SequenceDuration( number seqid = nil )
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.
Entity:SetAngles( Angle angles )
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.
Entity:SetAttachment( Entity ent, number attachment )
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.
Entity:SetBodygroup( number bodyGroupId, number subModelId )
Sets the currently active Sub Model ID for the Body Group corresponding to the given Body Group ID of the Entity's model. When used on a Weapon, this will modify its viewmodel.
Entity:SetBodyGroups( string subModelIds )
Sets the Entity's active Sub Models via a string of Sub Model IDs in order from the first Body Group ID to the last. This is a convenience function for Entity:SetBodygroup. When used on a Weapon, this will modify its viewmodel.
Entity:SetBoneController( number boneControllerID, number value )
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.
Entity:SetBoneMatrix( number boneid, VMatrix matrix )
Sets the bone matrix of given bone to given matrix. See also Entity:GetBoneMatrix. Despite existing serverside, it does nothing.
Entity:SetBonePosition( number bone, Vector pos, Angle ang )
Sets the bone position and angles. For changes to happen, this must be called in a rendering hook.
Entity:SetCollisionBounds( Vector mins, Vector maxs )
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.
Entity:SetCollisionBoundsWS( Vector vec1, Vector vec2 )
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.
Entity:SetColor( table color = Color(255, 255, 255, 255) )
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. When rendering a model manually via Entity:SetNoDraw inside ENTITY:Draw, you may need to use render. SetColorModulation in the render hook (where you call Entity:DrawModel) instead.
Entity:SetColor4Part( number r, number g, number b, number a )
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.
Marks the entity to call GM:ShouldCollide. Not to be confused with Entity:EnableCustomCollisions. Make sure to use Entity:CollisionRulesChanged after changing this value. Otherwise it can cause crashes.
Entity:SetCycle( number value )
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
Entity:SetDTAngle( number key, Angle ang )
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.
Entity:SetDTBool( number key, boolean bool )
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.
Entity:SetDTEntity( number key, Entity ent )
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.
Entity:SetDTFloat( number key, number float )
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.
Entity:SetDTInt( number key, number integer )
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.
Entity:SetDTString( number key, string str )
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.
Entity:SetDTVector( number key, Vector vec )
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.
Entity:SetEntity( string name, Entity entity )
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.
Entity:SetFlexWeight( number flex, number weight )
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.
Entity:SetHealth( number newHealth )
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.
Entity:SetIK( boolean useIK = false )
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.
Entity:SetKeyValue( string key, string value )
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.
Entity:SetLayerBlendIn( number layerID, number blendIn )
This function only works on BaseAnimatingOverlay entites!
Entity:SetLayerBlendOut( number layerID, number blendOut )
This function only works on BaseAnimatingOverlay entites!
Entity:SetLayerCycle( number layerID, number cycle )
Sets the animation cycle/frame of given layer. This function only works on BaseAnimatingOverlay entities.
Entity:SetLayerDuration( number layerID, number duration )
Sets the duration of given layer. This internally overrides the Entity:SetLayerPlaybackRate. This function only works on BaseAnimatingOverlay entities.
Entity:SetLayerLooping( number layerID, boolean loop )
Sets whether the layer should loop or not. This function only works on BaseAnimatingOverlay entites!
Entity:SetLayerPlaybackRate( number layerID, number rate )
Sets the layer playback rate. See also Entity:SetLayerDuration. This function only works on BaseAnimatingOverlay entities.
Entity:SetLayerPriority( number layerID, number priority )
Sets the priority of given layer. This function only works on BaseAnimatingOverlay entites!
Entity:SetLayerSequence( number layerID, number seq )
Sets the sequence of given layer. This function only works on BaseAnimatingOverlay entities.
Entity:SetLayerWeight( number layerID, number weight )
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.
Entity:SetLOD( number lod = -1 )
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.
Entity:SetModel( string modelName )
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.
Entity:SetModelScale( number scale, number deltaTime = 0 )
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:SetName( string mappingName )
Sets the mapping name of the entity.
Entity:SetNetworkAngles( Angle angle )
Alters the entity's perceived serverside angle on the client.
Entity:SetNetworked2Angle( string key, Angle value )
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.
Entity:SetNetworked2Bool( string key, boolean value )
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.
Entity:SetNetworked2Entity( string key, Entity value )
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.
Entity:SetNetworked2Float( string key, number value )
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.
Entity:SetNetworked2Int( string key, number value )
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.
Entity:SetNetworked2String( string key, string value )
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.
Entity:SetNetworked2Var( string key, any value )
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.
Entity:SetNetworked2VarProxy( string name, function callback )
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.
Entity:SetNetworked2Vector( string key, Vector value )
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.
Entity:SetNetworkedAngle( string key, Angle value = Angle( 0, 0, 0 ) )
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.
Entity:SetNetworkedBool( string key, boolean value = false )
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.
Entity:SetNetworkedEntity( string key, Entity value = NULL )
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.
Entity:SetNetworkedFloat( string key, number value = 0 )
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.
Entity:SetNetworkedInt( string key, number value = 0 )
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.
Entity:SetNetworkedNumber( any index, number number )
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.
Entity:SetNetworkedString( string key, string value = "" )
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.
Entity:SetNetworkedVar( string key, any value )
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.
Entity:SetNetworkedVarProxy( string name, function callback )
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.
Entity:SetNetworkedVector( string key, Vector value = Vector( 0, 0, 0 ) )
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.
Entity:SetNoDraw( boolean shouldNotDraw )
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. The entity can still be manually rendered via Entity:DrawModel in appropriate hooks.
Entity:SetNotSolid( boolean IsNotSolid )
Sets whether the entity is solid or not.
Entity:SetNW2Angle( string key, Angle value )
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.
Entity:SetNW2Bool( string key, boolean value )
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.
Entity:SetNW2Entity( string key, Entity value )
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.
Entity:SetNW2Float( string key, number value )
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.
Entity:SetNW2Int( string key, number value )
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.
Entity:SetNW2String( string key, string value )
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.
Entity:SetNW2Var( string key, any value )
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.
Entity:SetNW2VarProxy( string key, function callback )
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.
Entity:SetNW2Vector( string key, Vector value )
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.
Entity:SetNWAngle( string key, Angle value )
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.
Entity:SetNWBool( string key, boolean value )
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.
Entity:SetNWEntity( string key, Entity value )
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.
Entity:SetNWFloat( string key, number value )
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.
Entity:SetNWInt( string key, number value )
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
Entity:SetNWString( string key, string value )
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.
Entity:SetNWVarProxy( string key, function callback )
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.
Entity:SetNWVector( string key, Vector value )
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.
Entity:SetOwner( Entity owner = NULL )
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.
Entity:SetParent( Entity parent = NULL, number attachmentOrBoneId = -1 )
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.
Entity:SetPhysConstraintObjects( PhysObj Phys1, PhysObj Phys2 )
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.
Entity:SetPhysicsAttacker( Player ent, number timeLimit = 5 )
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.
Entity:SetPos( Vector position )
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
Entity:SetPoseParameter( string poseName, number poseValue )
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
Entity:SetPreventTransmit( Player player, boolean stopTransmitting )
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.
Entity:SetRagdollAng( number boneid, Angle pos )
Sets the bone angles. This is used alongside Kinect in Entity:SetRagdollBuildFunction, for more info see ragdoll_motion entity.
Sets the function to build the ragdoll. This is used alongside Kinect, for more info see ragdoll_motion entity in the game files.
Entity:SetRagdollPos( number boneid, Vector pos )
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.
Entity:SetRenderBounds( Vector mins, Vector maxs, Vector add = Vector( 0, 0, 0 ) )
Sets the render bounds for the entity. For world space coordinates see Entity:SetRenderBoundsWS.
Entity:SetRenderBoundsWS( Vector mins, Vector maxs, Vector add = Vector( 0, 0, 0 ) )
Sets the render bounds for the entity in world space coordinates. For relative coordinates see Entity:SetRenderBounds.
Entity:SetRenderClipPlane( Vector planeNormal, number planePosition )
Used to specify a plane, past which an object will be visually clipped.
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.
boolean Entity:SetSaveValue( string name, any value )
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. This is reset for players when they respawn (Entity:Spawn). Player ragdolls created with this enabled will have an owner set, see Entity:SetOwner for more information on what effects this has.
Entity:SetSkin( number skinIndex )
Sets the skin of the entity.
Entity:SetSolid( number solid_type )
Sets the solidity of an entity.
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.
Entity:SetSubMaterial( number index = nil, string material = "nil" )
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
Entity:SetSurroundingBounds( Vector min, Vector max )
Sets the axis-aligned bounding box (AABB) for an entity's hitbox detection. See also Entity:SetSurroundingBoundsType (mutually exclusive).
Automatically sets the axis-aligned bounding box (AABB) for an entity's hitbox detection. See also Entity:SetSurroundingBounds (mutually exclusive).
Entity:SetTable( table tab )
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.
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.
Entity:SetVar( any key, any value )
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)
Entity:SetWeaponModel( string viewModel, Weapon weapon = NULL )
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.
number Entity:SkinCount()
Returns the amount of skins the entity has.
boolean Entity:SnatchModelInstance( Entity srcEntity )
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
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.
Stops all particle effects parented to the entity and immediately destroys them.
Entity:StopLoopingSound( number id )
Stops a sound created by Entity:StartLoopingSound.
Stops the motion controller created with Entity:StartMotionController.
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.
Entity:StopSound( string sound )
Stops emitting the given sound from the entity, especially useful for looping sounds.
Entity:TakeDamage( number damageAmount, Entity attacker = nil, Entity inflictor = nil )
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.
Applies forces to our physics object in response to damage.
boolean Entity:TestPVS( any testPoint )
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.
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.
Entity:Use( Entity activator, Entity caller = NULL, number useType = USE_ON, number value = 0 )
Simulates a +use action on an entity.
Does nothing on server. Animations will be handled purely clientside instead of a fixed animtime, enabling interpolation. This does not affect layers and gestures.
Entity:UseTriggerBounds( boolean enable, number boundSize = 0 )
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.
Returns the index of this view model, it can be used to identify which one of the player's view models this entity is.
boolean Entity:Visible( Entity target )
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
boolean Entity:VisibleVec( Vector pos )
Returns true if supplied vector is visible from the entity's line of sight. This is achieved similarly to a trace.
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.
Entity:Weapon_SetActivity( number act, number duration )
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.
Returns the center of the entity according to its collision model.
Vector Entity:WorldToLocal( Vector wpos )
Converts a worldspace vector into a vector local to an entity
Converts world angles to local angles ( local to the entity )