I’ve been trying to apply bullet force to entities (Props only really) but for some reason my code will not actually do anything. I can be sure that all of my if statements are going through, but obviously at some point it just decides not to work. Any suggestions?
I have my function hooked on to GM:EntityTakeDamage
function PropPhysics(ent, inflictor, attacker, amount, dmginfo) if ent:IsValid() && !ent:IsPlayer() && !ent:IsNPC() then --Check that the entity is of the type we are looking for if inflictor:IsPlayer() then --Calculate the force multiplier to apply local weapMult = GAMEMODE.Multipliers.Weapons[weap] weapMult = weapMult && weapMult || 1.0 local forceMultiplier = GAMEMODE.CVars.PropKnockback:GetFloat() * weapMult --Store the velocity of the hit and the velocity of the object before hit local hitVel = dmginfo:GetDamageForce() local objectVelOld = ent:GetVelocity() --Calculate the force to apply to the object local objectVel = objectVelOld + (forceMultiplier * hitVel) --Apply the force to the object ent:SetLocalVelocity(objectVel) end end end
If you need any more information don’t hesitate to ask.