# Need Help Making Collision with Ground Work Correctly

**URL:** <https://forum.castle-engine.io/t/need-help-making-collision-with-ground-work-correctly/1025>\
**Category:** Uncategorized\
**Created:** [December 12, 2023, 4:08pm UTC](https://forum.castle-engine.io/t/need-help-making-collision-with-ground-work-correctly/1025 "2023-12-12T16:08:58Z")\
**Posts on this page:** 1\
**Showing post:** 87

<div class="post-metadata">

**Author:** ![JPF12141999](https://forum.castle-engine.io/user_avatar/forum.castle-engine.io/jpf12141999/32/1218_2.png) [@JPF12141999](https://forum.castle-engine.io/u/JPF12141999)\
**Post date:** [February 7, 2024, 11:21pm UTC](https://forum.castle-engine.io/t/need-help-making-collision-with-ground-work-correctly/1025/87 "2024-02-07T23:21:29Z")

</div>

And actually, you took that out of context! You omitted the last few lines that ended the block properly:

```auto
begin
  inherited;
  { This virtual method is executed every frame (many times per second). }
  SandyIdling := 0;
  SandyAirborne := 0;
  MaxDistance := 0.3;
  MoveAmount := Vector3(0, -5, 0);
  RayCastDirection := Vector3(0, -1, 0);
  RayCastResult := AvatarRigidBody.PhysicsRayCast(
  (AvatarTransform.Translation),
  RayCastDirection,
  0.3
  );
  if RayCastResult.Hit then
  begin
  SandyAirborne := 0;
  LabelFps.Caption := 'FPS: PLACEHOLDER';
      if SandyIdling = 0 then
      begin
  SandyIdling := 1;
  SandyLegs.PlayAnimation('LEGS_IDLE', true);
  SandyTorso.PlayAnimation('TORSO_IDLE', true);
      end
  else
  SandyIdling := 0;
  begin
    if SandyAirborne = 0 then
    begin
  SandyAirborne := 1;
  SandyTorso.PlayAnimation('TORSO_AIRBORNE', true);
  SandyLegs.PlayAnimation('LEGS_AIRBORNE', true);
    end;
  AvatarTransform.Move(MoveAmount, false, true);
  LabelFps.Caption := 'FPS: ' + Container.Fps.ToString
  end;
  // UpdateAimAvatar;
end;

```

And how the heck am I wrong about the lines after the code not affecting the code in any way, if I know 100% that I didn’t change the code after that one line and it worked fine earlier?

I thought that’s a basic technique of programming and troubleshooting for any language, a skill you suggest I lack?

It’s like saying that if a wire snaps in a circuit with many wires, then there is something wrong with the wires that didn’t snap and I should fix every last one, instead of only the wire I know is wrong, while there’s not actually reason to do that?

---

_[View the full topic](https://forum.castle-engine.io/t/need-help-making-collision-with-ground-work-correctly/1025)._
