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

I want to make sort of a crash up derby mod, but I can't get this to work. I kinda winged it, so I need to know what wrong. I get no syntax errors.

Code: [Select]
package CarCrash
{
function vehicle::oncollision(%vehicle,%obj,%col)
{
if(%vehicle.getvelocity() >= 10)
{
%vehicle.addhealth("-10");
echo("The car crashed!");
parent::oncollision(%vehicle,%obj,%col);
}
}
};
activatePackage(carcrash);


vehicle is not a class (or not one you are looking for).  You have to use something like wheeledVehicle or flyingWheeledVehicle .

vehicle is not a class (or not one you are looking for).  You have to use something like wheeledVehicle or flyingWheeledVehicle .
It starts with %this
Thanks to both of you, will try it now. I'll post back if I need any more help.

I'm guessing the new problem lies in the getvelocity() part. Am I doing that correctly, because I'm not seeing that stuff being echoed, which is a sign it is working.

It starts with %this

You should know variable names are interchangeable by now.

You should know variable names are interchangeable by now.
Most commonly it's %this and nothing else.
I'm not sure if Burger would understand.

Most commonly it's %this and nothing else.
I'm not sure if Burger would understand.
I just thought the names of args don't matter. whatever, thats over with now, I have the new problem now. :(

I just thought the names of args don't matter.

This is true; don't listen to much of what Kalphiter says, since he just thinks he knows what he's talking about.

vehicle is not a class (or not one you are looking for).  You have to use something like wheeledVehicle or flyingWheeledVehicle .

WheeledVehicle and FlyingWheeledVehicle inherit from the Vehicle class but because Torque polymorphism and inheritance is a joke, it often won't register these functions depending on when you define them.

Put an echo at the top of the onCollision to make sure it gets called first, otherwise try switching to WheeledVehicle.
« Last Edit: August 11, 2009, 02:52:18 PM by Ephialtes »

WheeledVehicle and FlyingWheeledVehicle inherit from the Vehicle class but because Torque polymorphism and inheritance is a joke, it often won't register these functions depending on when you define them.

Put an echo at the top of the onCollision to make sure it gets called first, otherwise try switching to WheeledVehicle.
Not seeming to work still. Code as of now:
Code: [Select]
package CarCrash
{
function wheeledvehicle::oncollision(%vehicle,%obj,%col)
{
echo("The car crashed!");
%vehicle.addhealth(-1000);
parent::oncollision(%vehicle,%obj,%col);
}
};
activatePackage(carcrash);
« Last Edit: August 11, 2009, 03:42:00 PM by Burger »

Not seeming to work still. Code as of now:
Code: [Select]
package CarCrash
{
function wheeledvehicle::oncollision(%this,%obj,%col)
{
echo("The car crashed!");
%vehicle.addhealth(-1000);
parent::oncollision(%this,%obj,%col);
}
};
activatePackage(carcrash);
It especially works if you don't make up variables, %vehicle.

This is true; don't listen to much of what Kalphiter says, since he just thinks he knows what he's talking about.
I never said it HAS to be %this, dumbass.

It especially works if you don't make up variables, %vehicle.
Well, I tried I fixed that, but I've used that already and it didn't work. There is obviously something wrong with the oncollision part because not even the echo is working.

Well, I tried I fixed that, but I've used that already and it didn't work. There is obviously something wrong with the oncollision part because not even the echo is working.
Sorry, just making sure you didn't forget to change %vehicle.