Author Topic: Vehicle::oncollision  (Read 1512 times)

What are you crashing into? Have you tried crashing at a low speed, just a nudge?

What are you crashing into?
He probably meant all other vehicles, not just anything.

I was directing the question to him. Given your lack of knowledge on this topic might I suggest you make an big boy decision and decide to just sit and watch? Callbacks depend on the classtype you're hitting.

I was directing the question to him. Given your lack of knowledge on this topic might I suggest you make an big boy decision and decide to just sit and watch?
You can't physically force me to.
:cookieMonster:

I'm guessing that I was doing this wrong lol. I was crshing into a wall. Didn't relize that it mattered.

I'm guessing that I was doing this wrong lol. I was crshing into a wall. Didn't relize that it mattered.

Yeah, Interiors and Terrain use the onImpact callback as I recall but collisions between two shapebase objects (players/other vehicles) will call the oncollision callback. You'll also need to fiddle with the impact member variables of the vehicle classes themselves since they contain minimum values for the touch to be considered an impact.

one last question, what do I name these:
Code: [Select]
package CarCrash
{
function wheeledvehicle::oncollision(%this,%obj,%col) //These args
{
echo("The car crashed!");
%this.addhealth(-1000); //The "%this part
parent::oncollision(%this,%obj,%col);
}
};
activatePackage(carcrash);

+edit: those args are fine, unless you want %this, %collider, %hit

I got it to work using the individual stuntplanevehicle datablock
Code: (Torque) [Select]
package crap
{
    function stuntPlaneVehicle::onCollision(%this, %obj, %col)
    {
echo(%obj TAB %col);
parent::onCollision(%this, %obj, %col);
    }
};
activatepackage(crap);

I cannot get it working using WheeledVehicleData or anything like that.

So, if you're only using one vehicle for this derby, go into it's script and find
datablock WheeledVehicleData(SpaceShuttleVehicle)
and replace.

Either you can ignore Kalphiter's posts and listen to me or I won't bother posting because he's just going to confuse you with his crap.

Either you can ignore Kalphiter's posts and listen to me or I won't bother posting because he's just going to confuse you with his crap.
It works, so ummm... what?

I gave him a simple way to do it for one vehicle.

Either you can ignore Kalphiter's posts and listen to me or I won't bother posting because he's just going to confuse you with his crap.
I think I'll go with you. lol

The problem here is you've been trying to register a callback for the vehicle object when it's a callback that belongs to the datablock, so you need to do the following:

Code: [Select]
function WheeledVehicleData::onCollision(%this,%obj,%col)
{
     echo("Colliding");
     Parent::onCollision(%this,%obj,%col);
}

Thanks.
When damaging a vehicle, what do I use. Addhealth does not work with vehicles.
« Last Edit: August 11, 2009, 04:32:13 PM by Burger »

You can do this:
Code: [Select]
%obj.damage(%sourceObject,%position,%damageAmount,%damageType);
or this for testing:
Code: [Select]
%obj.damage(0,0,1000);

as I believe, plain driving results in small bumps that would also be called by onCollision, you'd have to filter that.