Ignoring vehicle to vehicle collision
by Adam Beer · in Torque 3D Professional · 04/08/2010 (7:55 am) · 5 replies
The idea is for 2 vehicles to not have collision against each other but for those vehicles to collide against everything else. I am trying to do AI controlled aircraft and they hit each other too often so my best solution is to ignore collision when they touch. Any idea how to do that?
About the author
Adam is the owner of Ignition Games, an indie game and software development company.
#2
04/08/2010 (10:25 am)
I tried to remove VehicleObjectType from the sCollisionMoveMask as it looks like that is the mask used in updateWorkingList and that didnt do it. I then looked at Convex::updateWorkingList but that didnt help.
#3
04/08/2010 (10:40 am)
I don't have a lot of experience with vehicles,but I remember that I did something similar for the player class in past,so it is doable.The collision working list is the key to collisions - if your convex is not there,then you don't have a collision against it.
#4
In: T3D/vehicles/vehicle.cpp
function: Vehicle::resolveCollision
Directly after the line: Collision& c = cList[i];
Add this:
That should do it. You could probably more smoothly throw that into the existing if statement that follows, but my copy has serious edits there and I don't have a clean copy to compare against right now.
If you need something more specific, like having a datablock flag that allows you to disable collision vs vehicles for a specific vehicle class, just let me know and I can provide some code for it.
04/18/2010 (5:20 pm)
Well, you weren't too specific... if you just want to disable all vehicle collisions vs other vehicles, the following should work:In: T3D/vehicles/vehicle.cpp
function: Vehicle::resolveCollision
Directly after the line: Collision& c = cList[i];
Add this:
if (c.object->getTypeMask() & VehicleObjectType) continue;
That should do it. You could probably more smoothly throw that into the existing if statement that follows, but my copy has serious edits there and I don't have a clean copy to compare against right now.
If you need something more specific, like having a datablock flag that allows you to disable collision vs vehicles for a specific vehicle class, just let me know and I can provide some code for it.
#5
04/19/2010 (8:39 am)
Thanks Henry, that works very well.
Torque Owner Ivan Mandzhukov
Liman3D
Take a look at updateWorkingCollisionSet(),there is a call to updateWorkingList(),so you can create your own updateWorkingList() method that suits to your needs.
You can see how the free() method is used there and add an additional logic.