Problem with the bowling ball is that the pins that get knocked over wont knock over more pins.
The only way I could see bowling working is if you used players for pins, and tumble them if they get hit by either a ball, or a tumbled pin. This could end up being pretty laggy though. And some of you know what might end up happening.
Actually you could do items and do a constant collision loop once they were knocked over, maybe even a raycast that matches given velocity for maximum precision.
Worth trying imo
(untested) example:
function HeadGib::onAdd(%this, %obj)
{
%obj.monitorGibVelocity();
}
function Item::monitorGibVelocity(%this, %before)
{
cancel(%this.monitorGibVelocity);
%now = vectorLen(%this.getVelocity());
%delta = %before - %now;
if(%now <= 0.2)
{
%this.stopThread(0);
%this.rolling = false;
}
else
{
if (!%this.rolling)
{
%this.playThread(0, "roll");
%this.rolling = true;
}
%a = %this.getPosition();
%decal = spawnDecalFromRayCast(NewBloodDecal, containerRayCast(%a, VectorScale(VectorNormalize(%this.getVelocity()), 1.25), $TypeMasks::FxBrickObjectType))
if(%decal) %decal.unHideNode(blood @ getRandom(1, 2));
if(getRandom() < 0.7)
{
%decal = spawnDecalFromRayCast(NewBloodDecal, containerRayCast(%a, VectorSub(%a, "0 0 1"), $TypeMasks::FxBrickObjectType))
if(%decal) %decal.unHideNode(blood @ getRandom(1, 2));
}
}
%this.monitorGibVelocity = %this.schedule(50, monitorGibVelocity, %now);
}