I have to different Kinds of Colliders (“Environment” and “Mud”). The vehicle Physics should collide with the “Environment” Tagged Collider but not with the “Mud”-Tagged one. Is that possible?
My guess would be to set that up when the Car get’s Created in the vehicle.js script.
// Create vehicle
var tuning = new Ammo.btVehicleTuning();
var vehicleRayCaster = new Ammo.btDefaultVehicleRaycaster(dynamicsWorld);
var vehicle = new Ammo.btRaycastVehicle(tuning, body, vehicleRayCaster);
vehicle.setCoordinateSystem(0, 1, 2);
I’m afraid this is not possible with the default raycast vehicle in Ammo. In general, not related to btDefaultVehicleRaycaster, to filter out the raycast results, you would set a mask/filter on a raycast callback function. Internally, the vehicle raycaster is using a default raycast callback, which is set to default values, which is colliding with everything.
This is not impossible, though, but troublesome. Here are a few options, but all might be non-trivial:
Do not use btDefaultVehicleRaycaster, but create a rigidbody with 4 downward rays. Same setup as in btDefaultVehicleRaycaster, basically. Since you control the raycasts here, you can also set filters and masks bits. You would then have to manually control the forces applied to the rigidbody, depending on raycast results to balance the vehicle above ground.
Do not use raycasts, but a multibody connected with joints. You can have 2 back wheels as a single compound rigibody connected to the main body with a hinge joint, as they do not rotate left and right. Then use 2 hinge joints for the front wheels. One to rotate in place, another to rotate on local Y axis. You can also use only 1 hinge per front and back wheels and move the body by force, without relying on wheels friction. You would also have to apply additional forces on the main body to keep the vehicle in balance.