Funny Deaths...

Is there any way to add physics to a dead ragdoll? Example: A person gets shot in the head and does 3 backflips instead of falling over limp? I think it would be great for the gamemode I am trying to make!

EDIT: Atleast make it so they dont hit the ground, limp! I find it so boring. Is there a way to keep a bullets velocity going with the ragdoll?

**[Gamemode.DoPlayerDeath

http://wiki.garrysmod.com/favicon.ico](wiki.garrysmod.com/?title=Gamemode.DoPlayerDeath)** and **[Entity.SetVelocity

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=Entity.SetVelocity)** probably

Yeah, I saw a thread in here about a month ago, but I cannot seem to find it. I have searched and searched. The thread had the code, and I never took it. Wasn’t useful to me at the time. Anywho, it used both of those.

EDIT:


function GM:DoPlayerDeath( victim, killer, dmginfo )

	run_spectator( victim )
	victim:CreateRagdoll():SetGravity( 0.10 ) --gravity seems to not change
	victim:AddDeaths( 1 )

Does this work?

No you need an endin there and i would use a hook.Might have some errors really late and un-tested.
[lua]
function FunnyDeaths(ply, attacker, dmginfo)
ply:CreateRagdoll()
if !LocalPlayer():Alive() && LocalPlayer():GetRagdollEntity() then
local ent=LocalPlayer():GetRagdollEntity()
local head=ent:GetPhysicsObjectNum(10)
head:ApplyForceCenter(Vector(0,0,6000))
end
end
hook.Add(“DoPlayerDeath”,“FunnyDeathHook”,FunnyDeaths)

[/lua]

You’re using LocalPlayer() in a serverside script, use the variable you have already defined, ply.

Edited from ???'s post.

[lua]
function FunnyDeaths(ply, attacker, dmginfo)
ply:CreateRagdoll()
if !ply:Alive() && ply:GetRagdollEntity() then
local ent=ply:GetRagdollEntity()
local head=ent:GetPhysicsObjectNum(10)
head:ApplyForceCenter(Vector(0,0,6000))
end
end
hook.Add(“DoPlayerDeath”,“FunnyDeathHook”,FunnyDeaths)
[/lua]
Thats what you mean Drew, right?

Yea, though I’ve never used ApplyForceCenter or GetPhysicsObjectNum so I dunno if it’ll work, but the syntax looks correct. Though, don’t bother hooking it, just overwrite the default function, and tabbing properly helps me read it too. :smiley:

Yeah, should be better… :stuck_out_tongue: