# Collider and latest CGE?

**URL:** https://forum.castle-engine.io/t/collider-and-latest-cge/1224
**Category:** Physics and Collisions
**Created:** [June 8, 2024, 2:38pm UTC](https://forum.castle-engine.io/t/collider-and-latest-cge/1224 "2024-06-08T14:38:41Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![edj](https://forum.castle-engine.io/user_avatar/forum.castle-engine.io/edj/32/1701_2.png) [@edj](https://forum.castle-engine.io/u/edj)
#### Post date: [June 8, 2024, 2:38pm UTC](https://forum.castle-engine.io/t/collider-and-latest-cge/1224/1 "2024-06-08T14:38:41Z")

</div>

I updated cge from git to get the outlined triangles, which are great. But to build I found that anywhere I had a TCastleScene subclass and a `var Collider : TCastleMeshCollider` I had to rename my variable. No big deal, but I wonder what changed for Colliders? Is it still correct to initialize the collider you want and add it to the behaviors?

```auto
     MyCollider := TCastleMeshCollider.Create(Self);
     MyCollider.Mesh := result;
     MyCollider.Restitution := 0.3;
     result.AddBehavior(MyCollider);

```

---

<div class="post-metadata">

### Author: ![michalis](https://forum.castle-engine.io/user_avatar/forum.castle-engine.io/michalis/32/3_2.png) [@michalis](https://forum.castle-engine.io/u/michalis)
#### Post date: [June 9, 2024, 6:22pm UTC](https://forum.castle-engine.io/t/collider-and-latest-cge/1224/2 "2024-06-09T18:22:09Z")

</div>

That’s because we have introduced a property called `Collider` on `TCastleTransform`, see [Castle Game Engine: CastleTransform: Class TCastleTransform](https://castle-engine.io/apidoc/html/CastleTransform.TCastleTransform.html#Collider) . It’s a simple shortcut for reading `FindBehavior(TCastleCollider) as TCastleCollider`.

The FPC ObjFpc has a rule that prohibits from declaring a local variable whose name would conflict with class property. I have extended my document " Some differences betwen FPC ObjFpc mode and Delphi (and FPC Delphi mode)" to mention this, [Some differences betwen FPC ObjFpc mode and Delphi (and FPC Delphi mode) · michaliskambi/modern-pascal-introduction Wiki · GitHub](https://github.com/michaliskambi/modern-pascal-introduction/wiki/Some-differences-betwen-FPC-ObjFpc-mode-and-Delphi-(and-FPC-Delphi-mode)#in-objfpc-it-is-not-allowed-to-have-fieldvariableparameter-names-that-would-conflict-also-between-descendants-and-ancestors) .

This forces you to rename the variable indeed to something else (like we did in CGE examples too – [Fix physics\_asteroids to not have Collider · castle-engine/castle-engine@bbe7e95 · GitHub](https://github.com/castle-engine/castle-engine/commit/bbe7e9577b1afbc6bb9cbda187c2fefc189a156f) , [Fix compilation of platformer after TCastleTransform.Collider introduced · castle-engine/castle-engine@0c772d4 · GitHub](https://github.com/castle-engine/castle-engine/commit/0c772d40dd66b1c182604e6f652ef0188ce0107d) ). On the other hand, it makes your code a bit more future-proof: if you were allowed to have a local variable with name `Collider`, and removed that local variable during some refactor, then some lines accessing it (like `Collider.Restitution := 0.3;`) could still work but access now `TCastleTransform.Collider` by accident.

In short: Indeed you have to rename your local variables now from `Collider` to something else.
