If I wanted to add a function that would knockback players that get shot a certain amount depending on their current health, how would I go about doing that? I haven't been able to find anything on it on the gmod wiki and can't find a good tutorial anywhere.
So if a player got shot with a pistol it would add on the damage and then knockback the player instead of just doing the damage.
SetVelocity
You probably want to use the bullets velocity, then normalize it, and then multiply it by a force when applying a new velocity to the player. I'm not sure but I think you use the PhysicsObject, so if this method doesn't work, just get the PhysicsObject of the entities. So something along the lines of...
[code]
local force = 5;
ply:SetVelocity(ply:GetVelocity() + (bullet:GetVelocity():GetNormalized() * force));
[/code]
Sorry, you need to Log In to post a reply to this thread.