Author Topic: Efficient way to detect vehicle collsion for bricks?  (Read 409 times)

What would be an efficient way to detect vehicle collsion for bricks? I've tried all vehicle onCollision and onImpact stuff, got nothing.

It should be the onImpact function.
Here's a snip from the F18 code:
Code: [Select]
function F18Vehicle::onImpact(%this,%obj,%data)
{
%speed = vectorLen(%obj.getVelocity());

  //Lets the pilot have an easy landing
  if(%obj.f18gear == 2)
   %obj.speedlimit = 30;
  else
    %obj.speedlimit = 5;

  if(%obj.speed > %obj.speedlimit )
  {
    if(%obj.destroyed)
      return;
    %obj.setDamageLevel(0);
    %obj.destroyed = 1;
    %obj.finalexplosion();

    %obj.target.islocked=false;
    %obj.schedule(10,"delete");
    if(isObject(%obj.spawnBrick.client.minigame))
      %respawn = %obj.spawnBrick.client.minigame.vehicleReSpawnTime;
    %obj.spawnBrick.schedule(%respawn+1000,"spawnVehicle");
  }
  else if(%obj.speed < %obj.speedlimit)
  {
    %obj.applydamage(10);
  }

}

It'll probably go off when you hit more than bricks however, so I'd check to see what the last argument is, and see if you can slap a typemask on it.

A good thing to note is that onImpact will only be called when the vehicle's minimum impact speed is reached.

Get my Support_Impact_Damage script from here and check to see what I did, it works fairly well for brick collision.