Need Help Making Collision with Ground Work Correctly

Particularly because it was valid earlier,

And there weren’t any changes at all from then, like the line is exactly the same so it doesn’t make sense to suddenly stop working.

I know I did change lines before that, because I had to fix the wrong number of “begins” and “ends” as we talked about previously, but that error message doesn’t seem to be related to that problem at all, and I remember 100% that the original version before I edited it had the block with “begins” and “ends” directly before that, and compiled fine,

And I also didn’t edit any lines after that one, which is I omitted them, because I knew they couldn’t be causing the problem logically if they worked fine before without any changes, so I don’t know what the heck else is the culprit.

you’re wrong

you’re wrong

you’re the culprit

I suggested you learn to format the code correctly, I posted a clear example, and you post such a horror:

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;

I’m sorry my friend, but you don’t show any desire to learn, you’re not capable of being humble and recognizing that you know very little about programming. Someone has to tell you, and since now only I answer, and Michalis when he can…

I don’t even know why I insist on trying to help you, probably because being ignored in the forums is never nice. But honestly, I’m getting bored too.

Your mistake is as clear as day, and anyone who knows even the basics of Pascal can see it. Since you are obviously still learning this language, format the code correctly, as I already told you to do, and you will understand it immediately. Of course, you should first study how Begin End blocks work.

I did in fact study it, as “begin” marks the beginning of a block, and “end” marks the ending of a block, and I made sure to go back and physically count and write down the number of begins and ends.

The formatiing I chose was because the examples you showed me how to do it correctly were done in the same exact way, like I should indent nested blocks and what not.

I am in fact willing to learn, but if what the manual and you guys tell me to do word for word isn’t working, then how the heck am I supposed to actually understand anything?

Not only did I count the number of begins and ends, but also the Lazrus app I am using to develop the code highlights for me in a red rectangle around the code, and so I made sure to pay attention to how the “begins” and “ends” were highlighted;

for example I made sure in my “if-else” block the “begin” begins the beginning of the block correctly, and the “end” ends the decision block corectly, and the associated “end” isn’t somewhere later down the code, by paying attention to where the highlight is.

But it seems to you that this formatting:

is it the same as this one?

Because in this case I really don’t know how to get out of it…

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

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?

I understand from your last post you made while I was posting, that there were the wrong number of “begin” and "end"s, but I’m getting the error with my most recent post, and you should find for yourself when you analyze it carefully, that I did in fact pay attention to the correct number of “begin”'s and “end”'s.

There is no hope. I am sorry…

There is hope, but making condescending posts about “there is no hope” without actually explaining what I did wrong, when I post in detail how I pay attention to every single direction you and michaelis give me and that’s why I need help, is certainly not going to help me learn.

Because you will see I am always persistent and willing to try and try again, and I never say I lose hope or give up; why should you guys, if you are serious about helping me?

You did not count the begin and end correctly and the mistake in your code is really obvious. It is worrying that you cannot solve this problem on your own for 4 days (looking at dates at this forum thread).

Please perform the exercises below. Please do them all, don’t respond with incorrect statements like “heck, I know my code is correct” (your code is obviously not correct, the compiler is right). Please don’t skip any of the steps below. If you really want to learn, then please do these exercises to learn how to solve such issues in the future. Post your results in this thread.

  1. Go through the code you posted yourself in the post where you wrote “You omitted the last few lines that ended the block properly:” :

    Need Help Making Collision with Ground Work Correctly - #87 by JPF12141999

    Write down how many times the word “begin” occurs there.

    Write down how many times the word “end” occurs there.

    Is the count of “begin” and “end” equal?

  2. Use a text editor, like Lazarus or VS Code or really anything else, to search (using usually Ctrl +F shortcut) for “begin” in that piece of code. Count the “begin” occurrences this way.

    Similarly, count the “end” occurrences with the help of your text editor.

    Is the count of “begin” and “end” equal? Are the results equal to your manual counting from AD 1?

  3. As has been pointed out to you above, indent your code correctly. Modern Object Pascal Introduction for Programmers | Castle Game Engine and many other Pascal resources show how to do this. Your code is not formatted correctly.

    There are some variations how to make proper indentation, but the basic approach I most often saw with Pascal is:

    • lines after begin are indented by 2 more spaces.
    • ending a block with end moves back the indentation by 2 spaces less.
    • in effect, all matching begin and end should land on the same column. This should let you spot the mistakes trivially easily, without even needing to count like we did in AD 1 and AD 2.

    If the above description of indentation is unclear to you, look at the examples, from Modern Object Pascal Introduction for Programmers | Castle Game Engine , from CGE examples. They all follow these conventions.

  4. At this point you really should be able to solve the compilation error, at least the one with begin…end mismatched (I don’t know if you have other errors).

    You should still learn about begin..end blocks, as your code has 1 unnecessary block, and I suspect you don’t know where it is and why it is unnecessary. Follow all resources linked from More Resources to Learn Pascal | Castle Game Engine , read and watch there everything, until you understand it.

Note: I don’t give you ready solutions and answers above, because it doesn’t seem useful to me – it is another long thread from you, and it seems you do not know how to do very basic programming tasks. You need to learn them, I hope above pointers will be useful.

@JPF12141999 I see you created a GitHub issue about it, which I closed, Need Help with Coding a 3D Platformer Kid's Game · Issue #568 · castle-engine/castle-engine · GitHub . As I explained there, this is not a good idea. Do not fork the discussion from forum into a GitHub issue. GitHub issues are for things we can fix in CGE, not for support. Continue the discussion here.

And you still haven’t done what I asked you to do. Literally count the number of words “begin” and “end” in your code. The mistake in your code, that you posted both here and on GitHub, is incredibly obvious. Count the “begin” and “end”. Do it manually. Do it by text editor features like Ctrl+F. Compare the results. Write the results here – how many “begin”, how many “end” do you count in the code in the below image?

Follow the points I outlined in the post in this thread: Need Help Making Collision with Ground Work Correctly - #92 by michalis