Polarith AI
1.8
Physics Controller (2D)

front-end: AIMPhysicsController (AIMPhysicsController2D)

This controller is a debugging example for physics-based agents. Hence, a Rigidbody respectively a Rigidbody2D is required for it to work. The physics controller applies forces on the attached Rigidbody instead of translating and rotating the agent directly. The result is a much smoother movement compared to a direct controller (assuming that no artificial smoothing is applied). Since physics objects can be hard to get by, here is a suggestion on how to setup the Rigidbody properly such that it works well with the default parametrization.

  • LinearDrag = 5 (2D: 10)
  • AngularDrag = 10 (2D: 5)
  • GravityScale = 0 (2D only)

It is also possible to scale the applied Speed force with an objective by setting the ObjectiveAsSpeed parameter to a non-negative value. Note that this controller is available both for 2D and 3D setups.

Properties

This component has got the following specific properties.

Property Description
Torque Determines the maximum angular force which is applied. This parameter is dependent on the AngularDrag of the attached Rigidbody.
Speed Determines the maximum linear force which is applied. This parameter is dependent on the attached LinearDrag of the attached Rigidbody.
ObjectiveAsSpeed An index pointing to one of the context objectives. If it is negative, the objective values are ignored and the maximum force is applied. If it is referencing to a valid objective, the resulting magnitude is used to scale the applied force.
Mode (3D only) Passed through to Unity's Rigidbody.AddForce().
Context Reference to the targeted Context component. If this is not specified, the system uses the game object of this component to search for such a component.
Body / Body2D Reference to a Rigidbody(2D). If this is not specified, the system tries to use the appropriate component of the associated game object.

Remarks

For debugging purposes, this component is acceptable, but for production, you should definitely implement your own character controller which matches your application or game best.

The possibility to specify where the Context and Rigidbody(2D) components are located gives you the full control over the agent setup. So you can easily separate the agent representation from the AI and the controller into individual game objects.

Imprint