How would I go about using the Impact effect completely correct?
Not 100% if this is what you want but this is how the crowbar does it
local edata = EffectData()
edata:SetStart(spos)
edata:SetOrigin(tr_main.HitPos)
edata:SetNormal(tr_main.Normal)
edata:SetSurfaceProp(tr_main.SurfaceProps)
edata:SetHitBox(tr_main.HitBox)
edata:SetEntity(hitEnt)
if hitEnt:IsPlayer() or hitEnt:GetClass() == "prop_ragdoll" then
util.Effect("BloodImpact", edata)
self:GetOwner():FireBullets({Num=1, Src=spos, Dir=self:GetOwner():GetAimVector(), Spread=Vector(0,0,0), Tracer=0, Force=1, Damage=0})
else
util.Effect("Impact", edata)
end
You can find the arguments the effect uses here. Your Lua code should look something like:
local ed = EffectData()
data:SetOrigin(tr.HitPos) -- Position the impact effect is placed on
data:SetStart(tr.StartPos) -- Used to find the direction the impact came from
data:SetSurfaceProp(tr.SurfaceProps) -- Surface property to determine which impact decal/sound to use
data:SetDamageType(DMG_ENUM) -- Also used in determining the impact decal
data:SetHitBox(tr.HitBox) -- Used for attaching the decal trace to the ray bounded by the hitbox id. Using "0" will trace against the whole entity
local pEntity = tr.Entity
if (pEntity:IsValid()) then
data:SetEntity(pEntity) -- Entity to place the decal on
if (SERVER) then
data:SetEntIndex(pEntity:EntIndex()) -- Needed for serverside effects
end
end
util.Effect("Impact", ed)
He posted code from TTT.
Pretty much xd
Sorry, you need to Log In to post a reply to this thread.