Set a Model Animation

Hi, im coding my own Jumper using the V3 model. I have the animation names but how do i run them? This is what i’ve got.



function ENT:Draw()
	self.Entity:DrawModel()
	if LocalPlayer():KeyDown(IN_SPEED) then

		local sequence = self.Entity:LookupSequence("open")
		self.Entity:SetSequence("open_seq.SMD")
	end

	if LocalPlayer():KeyDown(IN_WALK) then
		
		local sequence = self.Entity:LookupSequence("close")
		self.Entity:SetSequence("close_seq.SMD")

	end
end


Thanks

The animations are all ready run

Yes sorry, thats what i’ve got to make them run but the problem is, the model goes invisible and nothing happens

I’ve just acquired the error from the console, its not a lua error i think…

Bad sequence (-1 out of 6 max) in GetSequenceLinearMotion() for model ‘Votekick/jumper/Jumper_V3.mdl’!



function ENT:Draw()
	self.Entity:DrawModel()
	if LocalPlayer():KeyDown(IN_SPEED) then

		local sequence = self.Entity:LookupSequence("open")
		self.Entity:SetSequence(sequence)
	end

	if LocalPlayer():KeyDown(IN_WALK) then
		
		local sequence = self.Entity:LookupSequence("close")
		self.Entity:SetSequence(sequence)

	end
end


Should work.

Thats the problem its not working for some reason. I have now made a hook in init.lua that sets the animation and then in cl_init.lua if you press shift the hook runs. But the animation is not working.

[editline]05:06PM[/editline]

Just incase you need it.

Init.lua:
[lua]

function ENT:OpenDriveAnim()

local sequence = self.Entity:LookupSequence("open") -- open_seq.SMD
self.Entity:SetSequence(sequence)

end

hook.Add( “Think”, “drive_pods_open”, OpenDriveAnim )

function ENT:CloseDriveAnim()

	local closePOD = self.Entity:LookupSequence("close_seq")
	self.Entity:SetSequence(closePOD)

end

hook.Add( “Think”, “drive_pods_close”, CloseDriveAnim )
[/lua]

cl_init.lua:
[lua]
function ENT:Think()
if( input.IsKeyDown(KEY_LSHIFT) ) then
if( not pressed ) then
pressed = true
hook.Call( drive_pods_open, gmod.GetGamemode() )
end
else
if( pressed ) then
pressed = false;
return
end
end
end
[/lua]

Also the Animation info:



$sequence open "open_seq.SMD" fps 15
$sequence close "close_seq.SMD" fps 15


Thanks

Ok so you’re switching constatly?

Basically, the i want the drive pods to open when you press shift, but the animation isn’t running no matter what i do. Any Help?

[lua]
function ENT:OpenDriveAnim()

local sequence = self.Entity:LookupSequence("open") -- open_seq.SMD
self.Entity:SetSequence(sequence)

end

hook.Add( “Think”, “drive_pods_open”, OpenDriveAnim )

function ENT:CloseDriveAnim()

	local closePOD = self.Entity:LookupSequence("close_seq")
	self.Entity:SetSequence(closePOD)

end

hook.Add( “Think”, “drive_pods_close”, CloseDriveAnim )

[/lua]

I meant them!! If you’re running them on the same time you really fuck it up!

Why the fuck you want to constantly set the animation? Just do it once.

I’ve got it doing what i want now its not a problem