Author Topic: Finding what a vehicle hits  (Read 1034 times)

So I need a script to figure out what exactly a certain vehicle has hit.

the package part is pretty easy:
Code: [Select]
package WtfAmHit
{
    function DriftingJeepVehicle::OnImpact(%this,%obj,%col,%pos,%speed)
    {
        //What now
    }
};
activatePackage(WtfAmHit);
%pos is highly unreliable, the given position is way off from where the collision occurs. %speed is only a scalar value, %col is always 0, and I don't have a clue what %this is.

I could do some stuff with container searches, but that is messy and I wanted to know if there is a cut and dry method before I jump all the way in.

Well of loving course I figure something out right after I post a topic.

Turns out the fourth argument in ::OnImpact is actually the velocity vector, not the position. I guess most of the BLF has gotten it wrong, because all of the search results have the fourth argument as %pos.
It probably doesn't help me much, but progress is progress.

%this is either the datablock of the drifting jeep or the instance of the drifting jeep

I believe %obj is literally the object that the vehicle hit.

%this is either the datablock of the drifting jeep or the instance of the drifting jeep

I believe %obj is literally the object that the vehicle hit.
%obj is the jeep
Would %this be the datablock of the thing it hit?


%obj is the jeep
Would %this be the datablock of the thing it hit?

No it is the drifting vehicle.

%col is what the object hit.

http://docs.garagegames.com/torque-3d/reference/classShapeBaseData.html#a20b5fdadf24208cf5e7ef53d0242747c
That's what it should be, but %col is always 0 every time, no matter what is actually hit.

No it is the drifting vehicle.
No stuff

That's what it should be, but %col is always 0 every time, no matter what is actually hit.

Well, if it's 0 you won't be able to find the collided object.

The zeroth parameter (auto-assigned by namespace) is the datablock.
The first parameter is the object which triggered a collision.
The second parameter is the object which the first parameter collided with.
The third parameter is the location where a collision was detected.
The fourth parameter is the vectorLen of the velocity of the first parameter at the point of collision.

Would %this be the datablock of the thing it hit?

No stuff? Your question doesn't look like one of no stuff..

Well, if it's 0 you won't be able to find the collided object.

The zeroth parameter (auto-assigned by namespace) is the datablock.
The first parameter is the object which triggered a collision.
The second parameter is the object which the first parameter collided with.
The third parameter is the location where a collision was detected.
The fourth parameter is the vectorLen of the velocity of the first parameter at the point of collision.
The third is the velocity vector, I just said that.
Any reason why the collided object is always 0? Any ways around it?

No stuff? Your question doesn't look like one of no stuff..
Oops my bad elm, thought you were telling me that %obj was the drifting jeep when I had just said it was the jeep





Badspot may have changed it. It's also possible that something else isn't parenting it right, but I have no idea what.

Either way, I tested it extensively and at least for me it's definitely the velocity vector

Try it with a default installation of Blockland.