Garry's Mod Wiki

Entity:SetSequence

  Entity:SetSequence( number sequenceId )

Description

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.

Arguments

1 number sequenceId
The sequence to play. Also accepts strings.
If set to a string, the function will automatically call Entity:LookupSequence to retrieve the sequence ID as a number.

Example

Set the entity to play the "idle" sequence.

self:SetSequence( "idle" )

Example

Set the entity to play the first sequence defined on the model (usually idle).

self:SetSequence( 0 )