Entity/SetSequence

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
(Better example of string acceptance)
Line 5: Line 5:
  
 
In some cases you want to run {{ClassFunction|Entity|ResetSequenceInfo}} to make this function run.
 
In some cases you want to run {{ClassFunction|Entity|ResetSequenceInfo}} to make this function run.
 +
 +
{{Note|This will not work properly if called directly after calling {{ClassFunction|Entity|SetModel}}. Consider waiting until the next Tick.}}
  
 
{{Note|Will not work on players due to the animations being reset every frame by the base gamemode animation system. See {{HookFunction|GM|CalcMainActivity}}.}}
 
{{Note|Will not work on players due to the animations being reset every frame by the base gamemode animation system. See {{HookFunction|GM|CalcMainActivity}}.}}
Line 15: Line 17:
 
|desc=The sequence to play. Also accepts strings.
 
|desc=The sequence to play. Also accepts strings.
  
If set to a string, the function will automatically call {{ClassFunction|Entity|LookupSequence}} to retrieve the sequence ID as a number.
+
{{Note|If set to a string, the function will automatically call {{ClassFunction|Entity|LookupSequence}} to retrieve the sequence ID as a number.}}
 
}}
 
}}
 
{{Example
 
{{Example

Revision as of 02:16, 21 June 2018

 Entity:SetSequence( )

Contents

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.

NOTE

This will not work properly if called directly after calling Entity:SetModel. Consider waiting until the next Tick.

NOTE

Will not work on players due to the animations being reset every frame by the base gamemode animation system. See GM:CalcMainActivity.

Arguments

number sequenceId

The sequence to play. Also accepts strings.

NOTE

If set to a string, the function will automatically call Entity:LookupSequence to retrieve the sequence ID as a number.

Examples

Example

Set the entity to play the "idle" sequence.

self:SetSequence( "idle" )


Examples

Example

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

self:SetSequence( 0 )


Personal tools
Navigation