```
function ENT:PhysicsCollide( data, physobj )
// Play sound on bounce
if (data.Speed > 80 && data.DeltaTime > 0.2 ) then
self.Entity: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
```

This is an excerpt from sent_ball, and controls the “bounce” of the ball. The particular lines in question are these:

local LastSpeed = math.max( data.OurOldVelocity:Length(), data.Speed )

Why does Garry look for the larger of two values? Why not just stick to data.Speed?

Speed appears to be the force of which the two entities collide - it seems fine by itself.

LastSpeed = math.max( NewVelocity:Length(), LastSpeed )

Now it gets even more confusing. Garry is looking for the largest value of physobj:GetVelocity(), data.Speed, and data.OurOldVelocity.Length().

Why?