Gameviewmain.pas(177,1) Warning: Symbol "TRigidBody" is deprecated: "use TCastleRigidBody"

Hello, I playing with Collision, and I wrote this code

{ TLeft }

TLeft = class(TCastleBehavior)
Stop: boolean;
constructor Create(AOwner: TComponent); override;
procedure Update(const SecondsPassed: single; var RemoveMe: TRemoveType); override;
procedure Collision(const CollisionDetails: TPhysicsCollisionDetails);

procedure TLeft.Update(const SecondsPassed: single; var RemoveMe: TRemoveType);
inherited Update(SecondsPassed, RemoveMe);
with Parent do
TranslationXY := TranslationXY + Vector2(100 * SecondsPassed, 0);


procedure TLeft.Collision(const CollisionDetails: TPhysicsCollisionDetails);

Box1 := TransformLoad('castle-data:/box.castle-transform', FreeAtStop);
Box1.Translation := Vector3(-400, 0, 0);
Box1.Scale := Vector3(3, 3, 3);
Box1.Collides := True;
Box1.Direction := ViewPort.Camera.Direction;
aLeft := TLeft.Create(FreeAtStop);

It’s works, but I got a Warning: Symbol “TRigidBody” is deprecated.
So I think there is a better way (or correct way) get the collisions event?

Any Idea



Hm, I don’t see in the code actually usage of TRigidBody.

Indeed it is deprecated – if you have it anywhere, you should change it to TCastleRigidBody (which is a bit different, but also better on all accounts).

If you want to detect when something collides, you’d use e.g. TCastleRigidBody.OnCollisionEnter event ( Castle Game Engine: CastleTransform: Class TCastleRigidBody ). The example examples/physics/physics_2d_collisions/code/gameviewmain.pas has some code to demonstrate this.

Hopefully this answer is helpful, if it’s not enough – please post a more complete source code, I’ll be able to help more precisely then :slight_smile:

Hello Michalis, thanks for answer. But I’m confused. I saw the exampled that you point. In the example, all components are created in editor, then in the code you can used.
But In my code I created a transform castle. Then I load it and I try to get collision.
I post a zip file with all code,may be can explain better than me (there is some garbage, but excuse me because it is a test code).

Thanks for all

/BlueIcaro (39.8 MB)

Everything that you can design in editor, you also create from code – just using the same class names, property names. examples/physics/physics_2d_collisions/ uses TCastleRigidBody class for behaviors :slight_smile:

Testing your example, I get a different warning at a similar line with latest CGE:

gameviewmain.pas(175,10) Warning: Symbol "RigidBody" is deprecated: "use AddBehavior (to set)/FindBehavior (to get)"

Solution: You should replace

Box1.RigidBody.OnCollisionEnter:[email protected];


Body1 := Box1.FindBehavior(TCastleRigidBody) as TCastleRigidBody;
Body1.OnCollisionEnter := @aLeft.Collision;

and declare Body1: TCastleRigidBody local variable in the routine.

I know – new version is longer. But it is more consistent with other behaviors, we decided for now to get rid of “RigidBody” shortcut that is also connected to deprecated “TRigidBody”. Maybe it will come back one day, I can see how it would be just convenient in this case.

Hello, thanks for the tip. Every is working!.
BTW. Your engine is amazing!.


1 Like