Garry's Mod Wiki

Revision Difference

CLuaParticle:SetCollideCallback#518189

<function name="SetCollideCallback" parent="CLuaParticle" type="classfunc"> <description>Sets the function that gets called whenever the particle collides with the world.</description> <realm>Client</realm> <args> <arg name="collideFunc" type="function">Collide callback, the arguments are:&#xA;&#xA;&#xA;&#xA;&#xA;&lt;page&gt;CLuaParticle&lt;/page&gt; particle - The particle itself&#xA;&#xA;&lt;page&gt;Vector&lt;/page&gt; hitPos - Position of the collision&#xA;&#xA;&lt;page&gt;Vector&lt;/page&gt; hitNormal - Direction of the collision, perpendicular to the hit surface</arg>⤶ <arg name="collideFunc" type="function">Collide callback, the arguments are:⤶ ⤶ ⤶ ⤶ ⤶ <page>CLuaParticle</page> particle - The particle itself⤶ ⤶ <page>Vector</page> hitPos - Position of the collision⤶ ⤶ <page>Vector</page> hitNormal - Direction of the collision, perpendicular to the hit surface</arg>⤶ </args> </function> <example> <description>Creates an explosion every time an particle collides with something.</description> <code> MyParticle:SetCollideCallback( function( part, hitpos, hitnormal ) --This is an in-line function local efdata = EffectData() --Grab base EffectData table efdata:SetOrigin( hitpos ) --Sets the origin of it to the hitpos of the particle util.Effect( "Explosion", efdata ) --Create the effect end ) </code> </example>