Game Development Community

Explosion Collision Radius

by Jeremy Alessi · in Torque Game Engine · 02/17/2005 (11:20 pm) · 5 replies

I've been searching but it doesn't seem there's anyway to adjust an affect radius for explosion collisions. Right now if an explision isn't within range of a mesh's collision box it doesn't affect the mesh ... as if the explosion only really occurs at a single point in space. Is there something I've missed or do I have to change the core to add this sort of effect? I want to do something a bit more like Halo where the grenades blowing up initiate a large radial effect throwing everything within a certain range away from the blast.

I already have the explosions throwing things away ... thing is you have to be really close to the explosion to get the effect and I want this to be adjustable.

#1
02/18/2005 (12:03 am)
I don't know about explosions pushing you back.

you could scripts it up pretty quick
here's some snips from one of the spells in my game

here is the main part that does the pushing, it uses some custom functions so you'll have to work around those...I think getNodePosition might be the only one you would need to change.. I included pushPlayerBack below

//Perform the spells effect
function PushSpell::onSpellCast(%this, %player)
{

	 //find all objects within a given radius of us
	 // and give them a nice push

    %pushForce = 30;
    %selfPushForce = 10;
    %radius = 10;// a nice big radius
    %mount_Pos = %player.getNodePosition("mount0");


	%pushableColiders = $TypeMasks::PlayerObjectType |
						$TypeMasks::CorpseObjectType;


 	InitContainerRadiusSearch(%mount_Pos, %radius, %pushableColiders);

 	while ( (%targetObject = containerSearchNext()) != 0)
 	{
		if(%targetObject != %player )
		{
			if (isObject(%targetObject))
			{
				%struck_pos = %targetObject.getWorldBoxCenter();
				%struck_normal = VectorNormalize(VectorSub(%mount_Pos , %struck_pos));
				//is it a player
				if (%targetObject.getType() & %pushableColiders)
				{
					pushPlayerBack(%targetObject, %struck_pos, %struck_normal, %player, %pushForce);
				}

			}

		}
	}


	//we need to play an effect here also.
    Parent::onSpellCast(%this, %player); //default spawns the cast emitter
 	alxPlay(Sound_SpellPush);



}

hmmm I have no idea why I'm checking this again inside of the while loop.
if (%targetObject.getType() & %pushableColiders)
I should only be getting pushableColiders from the InitContainerRadiusSearch will have to fix that.


here's the pushPlayer back helper function...it's misnamed should work on non players too.

function pushPlayerBack(%victim, %pos, %normal, %attacker, %impulseStrength)
{
	//%victim the thing to be pushed
	//%pos the point of collisions
	//%normal the normal of collision
	//%attacker the thing doing the pushing

	%pushDirection = VectorNormalize(%normal);
	%mass = %victim.getDataBlock().mass;
	%pushVec = VectorScale(%pushDirection, -1.0 * %impulseStrength * %mass);
	%victim.applyImpulse(%pos, %pushVec);
}

you could get even fancier and steal some of the code from radius damage that does less damage to you if you are behind cover.
#2
02/18/2005 (2:06 am)
Thanks a lot this should help out!
#3
02/18/2005 (2:31 am)
Just use RadiusDamage, it will damage objects within a specified radius, and push players away from the explosion.

radiusDamage(%sourceObject, %position, %radius, %damage, %damageType, %impulse);

%sourceObject is the object doing the damage(IE the player that shot the rocket or whatever).

Edit: Look in starter.fps/server/scripts/radiusDamage.cs to see how it works.
#4
02/18/2005 (11:12 am)
Yeah but in the code the radiusDamage function only gets called onCollision so I was looking for a way to extend the collision. I guess I could just call radiusDamage ... even with no collision ...
#5
02/18/2005 (11:22 am)
Doesn't seem to work ... and although there's also a projectile::explode function that doesn't seem to get it either. I'll check back maybe I made a slight error but it's not looking good.