Castle Game EngineIntroduction Units Class Hierarchy Classes, Interfaces, Objects and Records Types Variables Constants Functions and Procedures Identifiers
|
Class TRigidBody
Unit
CastleTransform
Declaration
type TRigidBody = class(TComponent)
Description
Rigid body properties for the physics engine, see TCastleTransform.RigidBody.
TODO: For now all the properties of this class, including the Collider and all properties of Collider, must be assigned before setting TCastleTransform.RigidBody .
Hierarchy
Overview
Methods
Properties
Description
Methods
 |
constructor Create(AOwner: TComponent); override; |
|
 |
destructor Destroy; override; |
|
 |
procedure Setup2D; |
Utility function to set common values for physics in 2D games. Locks moving along the Z axis, locks rotating along the X and Y axes.
|
 |
procedure InitializeTransform(const Transform: TCastleTransform); |
Connect this rigid body with Transform and Transform.World.
|
 |
procedure DeinitializeTransform(const Transform: TCastleTransform); |
Disconnect from Transform.World, if was connected.
|
 |
procedure Update(const Transform: TCastleTransform; const SecondsPassed: Single); |
|
Properties
 |
property InitialAngularVelocity: TVector3 read FInitialAngularVelocity write FInitialAngularVelocity; |
|
 |
property InitialLinearVelocity: TVector3 read FInitialLinearVelocity write FInitialLinearVelocity; |
|
 |
property Dynamic: boolean read FDynamic write FDynamic default true; |
Does the physics simulation move and rotate this object (because of gravity, or because it collides with others).
- true (
dynamic object, the default)
In this case you cannot change the TCastleTransform.Translation and other transformation properties of the related TCastleTransform after assigning TCastleTransform.RigidBody. They are under the control of the physics engine. You can still reliably read them.
Also, the value Animated is ignored in this case.
- false
In this case object is not transformed by the physics simulation. It still collides with other physical objects.
You can change the TCastleTransform.Translation and other transformation properties by your own code. But if you plan to change them very often (e.g. every frame), then set the Animated property to True .
|
 |
property Animated: boolean read FAnimated write FAnimated default false; |
Is the transformation of this object updated often (relevant only when Dynamic = False ).
This property is taken into account only if Dynamic = False . When Dynamic = False , you can change the TCastleTransform.Translation and other transformation properties of the related TCastleTransform. This property is an optimization hint to the physics engine, it says how often you will change the transformation.
- true (
animated object, also known as "kinematic")
The physics engine is prepared that this object can move often, e.g. every frame, so you can animate the related TCastleTransform using any technique.
- false (static object)
Changing the transformation properties is costly, it may even be like destroying this object and creating a new one from the point of view of the physics engine, so do not change them often, e.g. every frame.
The upside is that collisions with static objects may be much more optimized, since the physics engine can assume that all the static objects form a completely frozen unmovable geometry in the world.
|
 |
property Collider: TCollider read FCollider; |
Shape used for collisions with this object. You cannot assign this property directly, it is automatically assigned when you create a TCollider specifying this TRigidBody as it's parent.
|
 |
property Gravity: boolean read FGravity write FGravity default true; |
Is this object affected by gravity.
|
 |
property LockTranslation: T3DCoords read FLockTranslation write FLockTranslation; |
Disable motion (TCastleTransform.Translation change) along the particular (world) axis.
For 2D games, you will usually want to disable motion along the Z axis. Instead of directly changing this property, you can achieve this by calling Setup2D.
|
 |
property LockRotation: T3DCoords read FLockRotation write FLockRotation; |
Disable rotation (TCastleTransform.Rotation change) along the particular (world) axis.
For 2D games, you will usually want to disable rotation along the X and Y axes. Instead of directly changing this property, you can achieve this by calling Setup2D.
|
Generated by PasDoc 0.15.0.
|