ENT.PhysicsCollide

From GMod Wiki

Jump to: navigation, search
Event Hook
Hook NamePhysicsCollide
SyntaxENT:PhysicsCollide( Table :CollisionData data, Physobj physobj )
DescriptionControls what a scripted entity does during a collision
ReturnsNil
Lua StateNewerServer.png
BBCode[b][url=wiki.garrysmod.com/?title=ENT.PhysicsCollide]ENT.PhysicsCollide [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]


Examples

Descriptionsent_ball sample
Used onNewerServer.png
Code
function ENT:PhysicsCollide( data, physobj )
 
	// Play sound on bounce
	if (data.Speed > 50 && data.DeltaTime > 0.2 ) then
		self:EmitSound( "Rubber.BulletImpact" )
	end
 
	// Bounce like a crazy bitch
	local LastSpeed = data.OurOldVelocity:Length()
	local NewVelocity = physobj:GetVelocity()
 
	NewVelocity:Normalize()
	local TargetVelocity = NewVelocity * LastSpeed * 0.99
 
	physobj:SetVelocity( TargetVelocity )
 
end
OutputN/A


Additional Notes

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox