• pl:SetAnimation (Custom Anims)
    12 replies, posted
My friend built some Custom Anims, I have installed the .mdl file correctly and in the correct place, but for some reason the specified animations in this lua don't run, can anyone tell why? [lua] function SWEP:PrimaryAttack() local chance = math.random( 1, 2 ) local lefthand = self:LookupSequence("melee_jab") local righthand = self:LookupSequence("melee_hook") local pl = self:GetOwner() if SERVER then if self.Delay < CurTime() then self.Delay = CurTime() + .6 pl:EmitSound("weapons/slam/throw.wav",100,math.random(80,120)) if chance == 1 then pl:SetSequence(lefthand) else pl:SetSequence(righthand) end local ent = pl:GetEyeTraceNoCursor().Entity if ent and ent:IsValid() and ent:GetPos():Distance(pl:GetPos()) < 100 then ent:TakeDamage(math.random(10,20),pl) ent:EmitSound("weapons/crossbow/hitbod"..math.random(1,2)..".wav") end end end end [/lua]
[lua] local pl = self:GetOwner() [/lua] I think it's: [lua] local pl = self.GetOwner()[/lua] If not, do you have any errors?
[QUOTE=Commander11;29631218][lua] local pl = self:GetOwner() [/lua] I think it's: [lua] local pl = self.GetOwner()[/lua] If not, do you have any errors?[/QUOTE] Nope, that doesn't error. That's just telling the server that pl = the owner of the swep. That shouldn't really cause an issue... not to my knowledge anyway. There are no Errors, the Anim just doesn't play.
Use set sequence.
[QUOTE=Zoey Artyom;29631431]Use set sequence.[/QUOTE] [lua] pl:SetSequence( "melee_jab" ) [/lua] Still doesn't force the animation.
Are you trying to use the anim for the 3D Anim or the view model anim? I was saying that you have to use self:GetOwner like: self.GetOwner:SetAnimation(anim_enum) [url]http://wiki.garrysmod.com/?title=Player.SetAnimation[/url]
[QUOTE=Commander11;29631501]Are you trying to use the anim for the 3D Anim or the view model anim? I was saying that you have to use self:GetOwner like: self.GetOwner:SetAnimation(anim_enum) [url]http://wiki.garrysmod.com/?title=Player.SetAnimation[/url][/QUOTE] I'm trying to use a 3D Anim.
Then try what I suggested, it's on the wiki, but I wonder if it works with custom animations. If not, read up on [url]http://wiki.garrysmod.com/?title=Entity.SetSequence[/url]
[QUOTE=Commander11;29631218][lua] local pl = self:GetOwner() [/lua] I think it's: [lua] local pl = self.GetOwner()[/lua] If not, do you have any errors?[/QUOTE] Didn't work this produced errors, I've taken it down into 1 function rather than 3 Separate, now when you use Primary attack your leg twitches? Could this be a mess up in my friends animation/compiled version?
It won't work because Garry has hardcoded the enumerations into the engine. You can only use the animations\gestures included on default models unless you use the Lua Animations API. (which doesn't allow .smd animation import) To work around this you can rename the ACT_'s within the model to existing ones, which is hacky but gets the job done. Even though there are now functions to overlay gestures, we can't even use them with our own animation names, which is BS. I've PMed Garry about this a few times, but got no response.
May I ask where the hell the gestures are kept so I can decompile them and hack myself a custom anim? and maybe a tut?
pl:DoAnimationEvent([url=http://wiki.garrysmod.com/?title=Activity]ACT_ITEM_GIVE[/url]) That's the method I discovered that works but I have only begun my adventures in Lua programming. :0 I'm not sure if the default player models include the ACT_BUSY_ enumerations or not, but that will let you call any activity from the ones compiled into the animation libraries.
[QUOTE=UchihaItachi;29633559]May I ask where the hell the gestures are kept so I can decompile them and hack myself a custom anim? and maybe a tut?[/QUOTE] [URL]http://wiki.garrysmod.com/?title=Enumeration_List:Act[/URL] Tell your friend to compile the animations with one of those ACT_'s, preferably a remote-looking one that won't be used by the model anywhere other than in your code.
Sorry, you need to Log In to post a reply to this thread.