PhysicsCollide being called too early

Hey all, I decided to work on a swep that shoots a sent with particle effects, to look somewhat like a plasma weapon. I have an explosion particle effect that is called on ENT:OnRemove(), and it all works fine on single player, however, it seems that in multiplayer, it’s being called too early, or it’s something with prediction. It’ll be removed and the explosion effect will be off the wall/entity by quite a bit. Is there any way to sync the effect and such up to where it’ll be removed exactly when it hits a wall or entity?

I’ll provide some code if that doesn’t make sense.

The server and client aren’t always synced up in multiplayer, so most times there will be a little bit of off-ness. I’m not entirely sure if there is anyway to fix it but its the same thing with trailing hitboxes and whatnot.
The source engine is notorious for things like that.

I fixed it up, to where it hits entities directly, and I was using IsInWorld to have it correctly hit walls. However, it seems that IsInWorld doesn’t take thing walls into account. Is there any way to check if it’s on, or in a wall to trigger removing of the entity?

Why don’t you update a trace on each think and check if Hit && HitWorld?

Try firing the effects in **[ENT.PhysicsCollide](**, it’s called when your entity collides with another or the world.

It’s server side so if you are using client side effects, us the **[Entity.DTVar](** and **[ENT.SetupDataTables](**, and set a boolean for when the effects should fire, and check for it in the think of the client, and play the effect when it becomes true. Hope this helps.

Physicscollide was being weird, so I took Commander’s advice, and it works. Here’s a sample of how it works.


function ENT:Initialize()
    self:SetModel( "models/Gibs/HGIBS.mdl" )
    self:PhysicsInit( SOLID_VPHYSICS )   
    self:SetMoveType( MOVETYPE_VPHYSICS )  
        local phys = self:GetPhysicsObject()
        phys:SetBuoyancyRatio( 0 )
        if (phys:IsValid()) then
function ENT:Touch(HitEntity)
    if HitEntity:IsNPC() and HitEntity:Health() > 0 then
    timer.Simple(0.1, function() if self:IsValid() then self:Remove() end end)
function ENT:PhysicsUpdate( phys )
    local pos = self:GetPos()
    local ang = self:GetForward()
    local tracedata = {}
    tracedata.start = pos
    tracedata.endpos = pos+(ang)
    tracedata.filter = self.Owner
    local trace = util.TraceLine(tracedata)
    if trace.HitWorld then

The timer lets the sent get a bit closer to the entity it hit.
It’s pretty messy, but it works nicely. If there’s a better way to go about doing this, I’d love to know :slight_smile: