Giving my NPC the idle animation


AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
include( 'shared.lua' )

function ENT:SpawnFunction( id, tr )

	local trace = util.GetPlayerTrace( id, id:GetAimVector() )
	local tr = util.TraceLine( trace )
	local usi = ents.Create( "ts2_usi" )
	usi:SetPos( tr.HitPos + tr.HitNormal * 30 )
	usi:Spawn()
	usi:Activate()

end

function ENT:Initialize()

	self.ButtonSounds = {

	Sound( "vo/npc/female01/hi01.wav" );
	Sound( "vo/npc/female01/answer25.wav" );
	Sound( "vo/npc/female01/yougotit02.wav" );
	Sound( "ambient/voices/cough3.wav" );
	Sound( "vo/npc/female01/yeah02.wav" );

	}

	self.Entity:SetModel( "models/barnes/citizen/female_01.mdl" )
	self.Entity:PhysicsInit( SOLID_VPHYSICS )
	self.Entity:SetMoveType( MOVETYPE_VPHYSICS )
	self.Entity:SetSolid( SOLID_VPHYSICS )
	util.PrecacheSound( "vo/npc/female01/hi01.wav" )
	self.Timer = CurTime() + 2.5

end


function ENT:Use( activator, caller )

	if( self.Timer < CurTime() ) then
		self.Timer = CurTime() + 1
		
		self.Entity:EmitSound( table.Random( self.ButtonSounds ) )
	end
end

function ENT:StartTouch()

end

function ENT:EndTouch()

end

function ENT:Think()

end

It does everything I want it to do, works perfectly it just stands in a T shape with no animations. I would like to give it the Idle animation but I can’t find anywhere how to do it.

I foud this on the wiki but it doen’t give me an example.

Entity.ResetSequence is the function you’re looking for. Look at the example:
[lua]
local sequence = self.Entity:LookupSequence(“idle”)
self.Entity:ResetSequence(sequence)
[/lua]

Should be pretty straight forward :keke:

Thanks alot! But where do I put it? :3

Initialize


AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
include( 'shared.lua' )

function ENT:SpawnFunction( id, tr )

	local trace = util.GetPlayerTrace( id, id:GetAimVector() )
	local tr = util.TraceLine( trace )
	local usi = ents.Create( "ts2_usi" )
	usi:SetPos( tr.HitPos + tr.HitNormal * 30 )
	usi:Spawn()
	usi:Activate()

end

function ENT:Initialize()

	self.ButtonSounds = {

	Sound( "vo/npc/female01/hi01.wav" );
	Sound( "vo/npc/female01/answer25.wav" );
	Sound( "vo/npc/female01/yougotit02.wav" );
	Sound( "ambient/voices/cough3.wav" );
	Sound( "vo/npc/female01/yeah02.wav" );

	}

	local sequence = self.Entity:LookupSequence("idle") 
	self.Entity:ResetSequence(sequence) 

	self.Entity:SetModel( "models/Humans/Group01/male_02.mdl" )
	self.Entity:PhysicsInit( SOLID_VPHYSICS )
	self.Entity:SetMoveType( MOVETYPE_VPHYSICS )
	self.Entity:SetSolid( SOLID_VPHYSICS )
	util.PrecacheSound( "vo/npc/female01/hi01.wav" )
	self.Timer = CurTime() + 2.5

end


function ENT:Use( activator, caller )

	if( self.Timer < CurTime() ) then
		self.Timer = CurTime() + 1
		
		self.Entity:EmitSound( table.Random( self.ButtonSounds ) )
	end
end

function ENT:StartTouch()

end

function ENT:EndTouch()

end

Still in T shape.

At the bottom of your Initialize.


AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
include( 'shared.lua' )

function ENT:SpawnFunction( id, tr )

	local trace = util.GetPlayerTrace( id, id:GetAimVector() )
	local tr = util.TraceLine( trace )
	local usi = ents.Create( "ts2_usi" )
	usi:SetPos( tr.HitPos + tr.HitNormal * 30 )
	usi:Spawn()
	usi:Activate()

end

function ENT:Initialize()

	self.ButtonSounds = {

	Sound( "vo/npc/female01/hi01.wav" );
	Sound( "vo/npc/female01/answer25.wav" );
	Sound( "vo/npc/female01/yougotit02.wav" );
	Sound( "ambient/voices/cough3.wav" );
	Sound( "vo/npc/female01/yeah02.wav" );

	}


	self.Entity:SetModel( "models/Humans/Group01/male_02.mdl" )
	self.Entity:PhysicsInit( SOLID_VPHYSICS )
	self.Entity:SetMoveType( MOVETYPE_VPHYSICS )
	self.Entity:SetSolid( SOLID_VPHYSICS )
	util.PrecacheSound( "vo/npc/female01/hi01.wav" )
	self.Timer = CurTime() + 2.5

	local sequence = self.Entity:LookupSequence("idle") 
	self.Entity:ResetSequence(sequence) 

end 


function ENT:Use( activator, caller )

	if( self.Timer < CurTime() ) then
		self.Timer = CurTime() + 1
		
		self.Entity:EmitSound( table.Random( self.ButtonSounds ) )
	end
end

function ENT:StartTouch()

end

function ENT:EndTouch()

end

No dice.

Call it in the Use function or there is something wrong with your sequencing.