The Force Engine Documentation

1. Installation

  • Unpack the package into an empty project. Package dependencies will normally be automatically solved by unity.
  • Tick Allow unsafe code in Project Settings/Player/Other Settings menu.
  • Copy files from Assets/TF/Physics/ProjectSettings folder to ProjectSettings folder.

2. Components

The Unity scene should contain a TFEngine GameObject (GameObject with a TFEngine attached).

Then, in order for a GameObject in the scene to be part of the simulation, the following behaviours should be attached:

2.1 UnityEngine Collider and Rigidbody

These are used for first pass collision detection, to detect that two GameObjects are potentially colliding. TFCollider will automatically set the UnityEngine Collider to trigger and the UnityEngine Rigidbody to kinematics.

2.2 TFCollider

Similar to UnityEngine Collider. This is used to generate detailed collision information.

2.3 TFRigidbody

Similar to UnityEngine Rigidbody. Control of an object’s position through TF physics simulation.

2.4 TFMassBehaviour

This behaviour is used to set the mass and moment of inertia of TFRigidbody, according to the TFCollider shape and desired final mass or density.

2.5 TFResetScale

The engine supports scaling and nesting; this allows for example easy creation and attaching of boxes of various sizes.
This behaviour will bake the scale into the MeshFilter mesh vertices and into the Collider, then set the scale of the GameObject to {1, 1, 1}.

3. TFJoints

Similar to UnityEngine Joint; it is a relationship that is enforced between two bodies (or one body and the static environment) so that they can only have certain positions and rotations relative to each other.
This relationship is called a constraint; the words joint and constraint are often used interchangeably.

There are many kinds of TFJoints like the TFHinge joint.

A TFJoint behaviour is added to a GameObject and joint parameters such as position and axis are taken from the Transform.

If Body0 (body zero) is null then it means static environment.

4. Other Components

4.1 TFTrimesh

It is a triangle mesh collider that uses TFTrimeshData as data.
TFTrimeshData contains all triangles information in an optimised way. It is a ScriptableObject (belongs to the Unity project, not the scene) and can be used by many instances of TFTrimesh.
To create a TFTrimeshData:

  • Select Tools/The Force Engine/Create TFTrimeshData
  • Assign a Mesh
  • Press Create from Mesh button

4.2 TFTerrain

It is a terrain collider that uses TFTerrainData as data.
TFTerrainData contains all triangles information in an optimised way. It is a ScriptableObject (belongs to the Unity project, not the scene) and can be used by many instances of TFTerrain.
To create a TFTerrainData:

  • Select Tools/The Force Engine/Create TFTerrainData
  • Assign a Texture
  • Press Create buttons

5 Others

  • Add TFPROFILING preprocessor definition to see the profiling information panel
  • You will need an XBOX 360 controller to control the bike in the motocross demo.