How to Set Correct Collisions in Your Farming Simulator Mod

By Jason van Gumster, Christian Ammann

If you open the sample mod that comes with Farming Simulator, you should notice that a few objects render invisible. Some of them are collision objects for the vehicle mod, indicated by having _col as a suffix on their names. The wheels, the tractor’s body, and the cab have a collision object, and a large box in front of the tractor is a collision object to detect vehicles ahead.

Collision objects should be convex, meaning they shouldn’t have parts of the mesh that cut in on themselves, like a cave. If you need that kind of shape, you can make a compound object, where you use multiple convex collision objects to define your shape.

GIANTS Engine uses these collision objects to trigger events and calculate physics. However, just having an unrenderable mesh in your Scenegraph isn’t enough. The game engine needs to be made aware of that mesh’s purpose as a collision object. Unfortunately, this process is a bit of mystical art involving bitmasks.

In a way, it’s similar to how you paint foliage, just with a lot more possible checkbox combinations. Basically, the collision mask is a bitmask that defines what your collision object can collide with.

To define an object as a collision object within GIANTS Editor, first select it and make sure the Rigid Body checkbox is enabled in the Transform table of the Attributes panel. With this checkbox enabled, a new tab, labeled Rigid Body, appears in the Attributes panel. Click on that tab.

image0.jpg

The Collision Mask field is the first one after a set of checkboxes. Technically, you can manually type in a value, but you would really have to know what you’re doing for that work.

However, if you have a lot of the same kind of collision mask, you can copy and paste this value after you’ve set it for one of them. Make sure that the Collision checkbox is enabled and then click the ellipsis ( … ) to the right of the Collision mask field.

image1.jpg

At the top of the Collision Mask dialog is a series of checkboxes labeled from 0 to 31. Each checkbox represents a single bit that you can either enable or disable. The three text fields below that are numeric representations of the combination of bits you’ve enabled in binary (bin), hexadecimal (hex), and decimal (dec).

For the most part, those fields are purely informational. They’re automatically calculated as you enable and disable bits in mask. Here is a rough accounting of the various bitmask values and the features that they enable.

Bit Feature Bit Feature
1 non_pushable1 13 dynamic_objects_machines
2 non_pushable2 20 trigger_player
3 static_world1 21 trigger_tractors
4 static_world2 22 trigger_combines
6 tractors 23 trigger_fillables
7 combines 24 trigger_dynamic_objects
8 trailers 25 trigger_trafficVehicles
12 dynamic_objects 26 trigger_cutters
30 kinematic_objects_without_collision

If you haven’t already sorted it out, the fact that this mask of bits means that you can enable multiple ones at the same time. In fact, that’s exactly what you need to do, depending on the type of collision objects you have in your vehicle mod. Check out some common examples of bitmasks you may use.

Collision Type Bits Hex Value Decimal Value
Tractor 1, 6, 13, and 21 0x202042 2,105,410
Combine 1, 7, 13, and 22 0x402082 4,202,626
Fillable 1, 8, 13, and 23 0x802102 8,397,058
Cutter 1, 12, 13, 24, and 26 0x5003002 83,898,370
Tools 1, 13 0x2002 8194

The 0x at the beginning of the hex value is there as standard notation to indicate that the number is hexidecimal rather than decimal or some other numbering scheme.

The bitmasks for the tractor, combine, and fillable assume you’re setting them for the main body of those vehicles. If you’re setting collision masks on sub-objects like wheels, then the trigger bit in each of them isn’t usually necessary. That is, for a tractor wheel collision mask, you only need to enable bits 1, 6, and 13. Bit 21 can remain disabled.

For these exporters, you typically have to enter the hexidecimal value for the bitmask. The GIANTS Editor interface is currently the most straightforward means of setting the collision mask, so it’s a good idea to wait until after exporting to define your bitmask.