Entity.PhysicsCollide.
You can use it on entities that you didn't make by overriding their PhysicsCollide method.
-- myEnt is my entity.
local oldPhysicsCollide = myEnt.PhysicsCollide
function myEnt:PhysicsCollide(data, physobj)
-- Do shiz.
oldPhysicsCollide(self, data, physobj)
end
I told you to look a the bouncy ball's code:
--[[---------------------------------------------------------
Name: PhysicsCollide
-----------------------------------------------------------]]
function ENT:PhysicsCollide( data, physobj )
-- Play sound on bounce
if (data.Speed > 80 && data.DeltaTime > 0.2 ) then
self:EmitSound( "Rubber.BulletImpact" )
end
-- Bounce like a crazy bitch
local LastSpeed = math.max( data.OurOldVelocity:Length(), data.Speed )
local NewVelocity = physobj:GetVelocity()
NewVelocity:Normalize()
LastSpeed = math.max( NewVelocity:Length(), LastSpeed )
local TargetVelocity = NewVelocity * LastSpeed * 0.9
physobj:SetVelocity( TargetVelocity )
end