Polarith AI
1.8
AIMPhysicsController2D Class Reference

Description

A very simple and basic physics-based controller component suitable for the use in 2D projects.

The purpose of this controller is to show the AI results under the assumption that there is physics involved for the movement so that the resulting AI outputs are smoothed over time through using forces. It rotates the up vector of the agent towards the direction decided by the AI and translates along. Furthermore, it is assumed that the character moves in parallel to the x/y-plane. Requires an AIMContext and Rigidbody2D component. If Context or Body2D are null, this controller attempts to get these components in the OnEnable method. If they are still null, the controller will stay disabled.

Note, if there is also a Collider2D, the applied forces behave differently. So all default parameterizations are made for an existing Collider2D, whereby Rigidbody2D.gravityScale is 0, Rigidbody2D.drag is 5 and Rigidbody2D.angularDrag is 10.

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.

Only one single component can be attached to one GameObject at a time.

Inheritance diagram for AIMPhysicsController2D:

Public Fields

float Torque = 0.05f
 Determines the base value of the applied force for rotating the character towards the decided direction. More...
 
float Speed = 10f
 Determines the base value specifying how fast the character moves. More...
 
int ObjectiveAsSpeed = -1
 If set equal to or greater than 0, the evaluated AI decision value is multiplied to the Speed. More...
 
AIMContext Context
 The AIMContext which provides the next movement direction that is applied to the Body2D. More...
 
Rigidbody2D Body2D
 The Rigidbody which is manipulated by this controller. More...
 
Imprint