I just want the player to play the flinch animation in third person, preferably server-side but client-side is good too. How do I do this?
DoAnimationEvent seems to do exactly that
I tried that with PLAYERANIMEVENT_FLINCH_CHEST but nothing happened when going into thirdperson in console
Maybe the flinch is a gesture instead of an animation. Maybe AnimRestartGesture?
ply:AnimRestartGesture( GESTURE_SLOT_FLINCH, ACT_FLINCH_CHEST, true )
Huh. I wonder why the chest doesn't work. I'll use this for now but if I find something else I'll probabaly use that
The problem is the flinch activities not existing on the player in those exact forms - I'm currently making a fix to PR.
Ty. Also, isn't [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/LookupSequence]Entity:LookupSequence[/url] meant for finding out the ID of a sequence that may or may not exist on the entity?
LookupSequence are for sequence names, like "die" or "shoot". To find sequences by activity enums, use Entity:SelectWeightedSequence
Hmm. I looked into all the functions related to this method and I think I have something. I'm about to test...
hook.Add("CalcMainActivity", "playerflinchvar", function(ply,vel)
local EnumToSeq = ply:selectWeightedSequence(ACT_FLINCH_CHEST)
if ply:GetNWBool("flinchnow", false) then
ply:ResetSequence(EnumToSeq)
ply:SetNWBool("flinchnow", false)
return end
end )
function flinchplayer(ply)
ply:SetNWBool("flinchnow", true)
end
Results
Nope.
That activity doesn't exist on players.
That code is gonna throw out an error, you used a lowercase 's' in SelectWeightedSequence
Yep, I fixed that a while ago.
How do I get it to work?
I never did player animation stuff before, but maybe use this instead
Drafted this:
-- server.lua
function flinchplayer(ply)
net.Start("flinchplayer")
net.WriteEntity(ply)
net.Broadcast()
end
-- client.lua
net.Receive("flinchplayer", function(leng,ply)
local vic = net.ReadEntity()
local EnumToSeq = vic:SelectWeightedSequence(ACT_FLINCH_CHEST)
vic:AnimRestartGesture(GESTURE_SLOT_FLINCH, EnumToSeq, true)
end )
(The wiki page says it wasn't automatically networked)
Can't wait to test...
Nope. I think I might have to override the rendering of the player but I don't even know where to start with that.
Reading back, didn't code_gs say that ACT_FLINCH_CHEST does not work on players? If that is the case, you can do nothing about it. Try a activity to see if that one works, and if so, it is a problem with the activity rather than the code.
Sorry, you need to Log In to post a reply to this thread.