You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.
Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.
for i=0 to 300 // Way to limit collision count for performace, however the Phy Collision collection is extremely fast.
if not phy get collision data ( )
exit // Exit if no collisions exists
a = phy get collision object a ( )
b = phy get collision object b ( )
// ----- Collect collisions for first group.
// Get the collisions of objects in the range 1 to 100. Make more loops just like this one to differ between object groups.
// Group should be prepared before. In this example we assume:
// Barrel objects ID range 1 to 100
// Crates, 101 to 200
// Then we can handle them seprarately playing a metal sound for the first group and a wood sound for the crates.
ObjectGroupIndexStart = 1
ObjectGroupIndexEnd = 100
if a>=ObjectGroupIndexStart Then if a<ObjectGroupIndexEnd
// Collect collisions for object a against b, another for loop has to be done to check the other way.
for j=0 to PHY GET COLLISION COUNT ( a )
// Collect all the force the object is suffering for the collision "j".
Inc Force#, phy get collision normal force x(a , j)
Inc Force#, phy get collision normal force y(a , j)
Inc Force#, phy get collision normal force z(a , j)
if Force#>ForceThreshold# // way to exclude small bumps and rolling, continue...
// Collect contact points.
ContactX#=Phy Get Collision Contact Point X(a , j)
ContactY#=Phy Get Collision Contact Point Y(a , j)
ContactZ#=Phy Get Collision Contact Point Z(a , j)
// Check the angle of the collision, here we only get the angle of the "ground" polygon hit i.e Y
NormalY# = Phy Get Collision Contact Normal Y(a ,j)
//As this object is in the 1 to 100 group it is a barrel.
if NormalY# < -0.75
// The bounce is on a object that is pretty flat and facing up, we assume it is the ground.
SpawnDirtCloudParticle(ContactX#, ContactY#, ContactZ#, Force#)
exit // We only collect one collision here. Remove this to collect all collisions in PHY GET COLLISION COUNT ( ID ) (the j loop)
// ----- End Collect collisions for first object group
Login to post a reply