Missile's and wall's not getting along
by Tom Feni · in Torque Game Builder · 07/18/2005 (11:08 pm) · 3 replies
Ok, well I have missiles shooting and colliding with walls.. works great and they even delete themselves at the wall.. but thats where the fun ends and the problems begin..
ok a little code..
now when it explodes at the wall the explosion appears at the center of the tile map and not at the wall...
not very realistic.. :)
I am thinking that its a oncollision callback but not sure how.. :)
ok a little code..
function playerFire()
{
// Create player projectile.
%projectile = new fxStaticSprite2D() { scenegraph = t2dSceneGraph; };
%projectile.setSize( "3 1.5" );
%projectile.setImageMap( playermissileImageMap );
%projectile.setLinearVelocityX( 35 );
%projectile.setPosition( $player.getLinkPoint($player.fireLinkPoint) );
// Setup collision info
%projectile.setGroup( 1 );
%projectile.setLayer( 0 );
%projectile.setCollisionPhysics(true, false);
%projectile.setCollisionActive(true, false);
%projectile.setCollisionMaterial(freeflowMaterial);
%projectile.setCollisionScale("0.9 0.5");
%projectile.setCollisionMasks(0xffffffff, 0xffffffff);
%projectile.setCollisionCallback( true );
}function createExplosion( %object )
{
// Ignore if object not around anymore.
if ( !isObject(%object) )
return;
// Shockwave Explosion.
%explosion = new fxParticleEffect2D() { scenegraph = t2dSceneGraph; };
%explosion.loadEffect("t2d/client/effects/shockwave_burst.eff");
%explosion.setPosition( %object.getPosition() );
%explosion.setEffectLifeMode( kill, 0.5 );
%explosion.playEffect();
}now when it explodes at the wall the explosion appears at the center of the tile map and not at the wall...
not very realistic.. :)
I am thinking that its a oncollision callback but not sure how.. :)
About the author
Torque 3D Owner Tom Feni
function fxSceneObject2D::onCollision( %srcObj, %dstObj, %srcRef, %dstRef, %time, %normal, %contactCount, %contacts ) { // Create an explosion for the collision that just occurred createExplosion( %dstObj ); if (%srcObj == $player) { KillPlayer(); %dstObj.safeDelete(); } else if (%dstObj == $player) { KillPlayer(); %srcObj.safeDelete(); } else { %srcObj.safeDelete(); %dstObj.safeDelete(); } }I probably need something in here to tell it to explode at the point of contact..
but thne I have newbish intentions.. :)