Author Topic: Spawning a projectile where it hits.  (Read 2025 times)

Is that possible? Example included,

Very possible, but right now I cant scrounge up the code.
Check wrench events shooting, perhaps, or something else that launches projectiles.

Brick piercing railgun? :cookieMonster:

It's possible, but if you want it to happen with a gravity based weapon (throw spear 'through' a wall and it keeps in the same flight path) you're going to have to use random calculations to figure out what angle it was falling it etc. For timer weapons, look at the Portal Gun to see how it 'forces' a Grenade or other such weapon to explode on time when thrown through portals.

Brick piercing railgun? :cookieMonster:

It's possible, but if you want it to happen with a gravity based weapon (throw spear 'through' a wall and it keeps in the same flight path) you're going to have to use random calculations to figure out what angle it was falling it etc. For timer weapons, look at the Portal Gun to see how it 'forces' a Grenade or other such weapon to explode on time when thrown through portals.
If this is made,we could decide what is faster, the blockhead or the projectile   :cookieMonster:

Not really brick, player-piercing.

I haven't tried this, but it should work
Code: [Select]
function MyProjectile::onCollision(%this, %projectile, %obj, %fade, %trans, %norm)
{
   if( %obj.getClassName() $= "Player" || %obj.getClassName() $= "AIPlayer" ) // Only respawn if it hits a player...
   {
      new Projectile()
      {
         dataBlock = %this;
         initialVelocity = %projectile.getVelocity();
         initialPosition = %projectile.getPosition();
         sourceObject = %projectile.sourceObject;
         sourceSlot = %projectile.sourceSlot;
      };
   }
}
« Last Edit: February 24, 2008, 03:19:38 PM by exidyne »

That seems similar to the code that qwertyuiopas sent me (yeah, he's still trying to get unbanned).

I'll try both out later.

it may spawn right where it hit causing insant death(hit, new projectile, hit again, ect)

You may want to try spawning it a bit further along its flight path.

It's for an instant kill weapon, so I'm not sure what you mean.

I'd also like to know if it's possible to make it a hitscan weapon instead of a projectile one.

What I mean is that if it did less than instant kill damage and you shot it at someone, it would spawn where it hit, hitting the player again, and respawning in the same place over and over untill they died and it could get through. I think.

Well, the weapon does 300 damage (a bit much, no?), so that's not a problem.


The best way would be to find a place just PAST where the projectile collides.

How you could do that, no idea.

exid, where would I put that portion of the script? I tried the very bottom, but it didn't work.

Code: [Select]
...
   initialPosition = VectorAdd(%projectile.getPosition(), VectorScale(%projectile.getForwardVector(), 2));
...

Make sure you changed 'MyProjectile' to the name of your projectile datablock.
« Last Edit: February 24, 2008, 10:19:15 PM by exidyne »