Crouching Problem, BugFix

Hi there, i have a new Problem to be solved.

now my Gunnar can crouch and duck. If he does, his HitPointBox will change to a new animation (with a smaller Hitbox in height, so he can crouch under Blocks.

So far, so good.
But if he is not anymore in collision with a block, he will stand up - thats fine! But if he crouches ON TOP of a block, he is still in collision with the block so he cannot stand up. Weird.

So i thought:
Not :
IF Player is in Collision with the block
so:
IF PlayerHitPoint.PointX("Head);PlayerHitPoint.PointY("Head) is in collision the block.

I did this to check if the Player stands on top of a Trampoline to jump higher and it worked.

But if i change to: “PlayerHitBox.PointX(“Kopf”);PlayerHitBox.PointY(“Kopf”)” (so that’s the way i named it) the player stays crouched forever - if there is a block or not.

The only thing i Changed ist the
If Gunnar is in collision with a platform
to
If PlayerHitBox.PointX(“Kopf”);PlayerHitBox.PointY(“Kopf”) is in collision with a platform.

Any Ideas?

Have you tried enabling the hitbox debugging?
Maybe it’ll help you understand what’s going on.
image

2 Likes

Great tip, thank you!

I checked it out, everything looks like it should.

Can you show updated events with the PointX stuff?
And perhaps in-game screenshot of the issue?

1 Like

As Gruk said, can you show the updated events? I’m assuming you haven’t solved the problem yet.

1 Like

Hi there, solved so many other problems meanwhile, but not this one.

So there is nothing great to show. As i said i replaced all the “If Gunnar is in collision with Plattformen”
with
“If PlayerHitBoxPointX(“Kopf”);PlayerHitBoxPointY(“Kopf”) is in Plattformen”

As is see in the Draw collisions Debugger Tool the Point “Kopf” is set correctly, but it doesnt work.

Ah, good. I just wanted to know the exact event.
While I’m recreating the system, could you check some things?

Could you have a text object show the values of ducken and kriechen to see if they’re both 0 when you exit the crawling part.
If so, check if there’s something that resets the animations to normal if the player’s not ducking or crawling.

EDIT: This is tough…
Try putting the event that says
“NOT if down key pressed and NOT if gunnar’s head in collision with platform: Ducken and Kriechen and gunnar animation = 0”
at the very end…

1 Like

I’ll try it out now, give me a few minutes…

So i changed everything back to the PointX and Y thing and added some Textfields to check what’s going on…

I think it´s interesting. Only by replacing “If Gunnar is in collision” to “PlayerHitPoint.PointX…”, my Player is interacting with Platformen in a completely different way.

Now he´s interacting more crazy, buggy. But now if he stands on “Plattformen”, he has no more Problems to stand up, of course, because his head (“Kopf”) is free.

And another Problem.
If he is in crouching mode and does not move, but i still presses down, he should go to duck mode, but he stays in crouching mode.

Look at this:

OKOKOK, now i get a step closer! think so. perhaps not. perhaps i´m stupid.

Short walk to another thing - my teleporter. Think of it as the green tubes from mario to get to the secret worlds under the ground.

First i had:
If PlayerHitbox is in collision with Teleporter and presses down: teleport him.
It worked but it also worked when the player stands near the Teleporter.
So i added a Point “PlayerCheck” above the Object “Teleporter”.
As you can see in the “code”, now he checks both. Now the Teleporter only works, when the Player is on top of the Teleporter. Fine.

But - and now i´m getting confused:
It says in the red box:

  1. Is PlayerhitBox in collision
  2. is down Button pressed
  3. is PointXandY in Playerhitbox.
  4. Trigger once.

Thats the way it works very fine!

now in my understanding, if i change the change the conditions 1,2,3,4 to per example 2,1,3,4 or 3,1,2,4 or what combination ever, it should work the exact same way. But it doesn´t.

Also, in my understanding, i don´t need the “If PlayerHitBox is in collision with Teleporter” while i have the “If Teleporter.PointX(“PlayerCheck”);Teleporter.PointY(“PlayerCheck”) is in PlayerHitbox” - right?

But it won´t work. Only in this way 1,2,3,4 it works. Makes no sense for me. But ok, i´m still new to all of this.

Phoo. At this point, I’d say the best course of action would be to strip down everything to its bare components and try to start from scratch. Simple is best.
The point collision thing gave me some trouble. I don’t know exactly why. So, I just used the same variable I used for the text. Worked like a charm!

1 Like

Thank you so much Sciller4, ill try it out.

But first here my experience with the Point collision thing - interesting, isn´t it?

Hm. Those actions are very weird. And usually, the condition layout doesn’t matter. But, I think I may understand…

The “is down Button pressed” can be put anywhere from 1-3. It does not have an effect, it seems.
The “Trigger once” I have recently posted on the forum about. It actually matters whether it is at top or at bottom. It seems to be the best practice that you should just put it at the bottom, always.
Here is Arthuro’s explanation.

So it seems that conditions 1 and 3 are the culprit!
I think what happens is, if you do the PointXpointY one first, it does not know for which teleporter to check. I’m guessing it checks just the first one you made.
Meanwhile, if you use “PlayerHitBox in collision” first, then it will know which teleporter to check - the one that is in collision with the player.
This seems to be a common problem. If that’s the case, I hope the action gets rethought or documented in the wiki…

@CHammer1981
Please open one topic per issue.

Yes, event order matters, as @Sciller4 explained, the conditions tell GDevelop which object instances the actions should be applied to.
http://wiki.compilgames.net/doku.php/gdevelop5/tutorials/basic-game-making-concepts#events_and_how_objects_are_selected_by_these_events

Thank you Gruk, but for my problem with the PointX and Y for crouching i thought it could be helpful. As i wrote, the Teleporter thing works fine, but it thought if i understand why the teleporter works this way, i could figure out why the crouching thing does not. both are made this PointX and Y thing. There was no new issue. I´m new at Gdev, but not new in forums. :wink: Anyway, i thank you for your thoughts and help. Sometimes the language is my problem to tell what i exactly mean. School is 25 years over. My german is better :slight_smile:

So thank you very much Sciller, i think you found the point… first be in collision, so he knows which object is to be checked for the PointX and Y story. Cant wait to test it your way, but for now (it´s late here) i have to eat and sleep.

1 Like

Hi there again. Bad news, It does not work.

Tried to copy your way but the result is the same as before. The animations dont’t work, but i found the mistake. You set the “crouch” variable to 1, but the “duck” variable still was 1. So i changed it and now the animations work fine as before.

But now the exactly same issue as before:
When he stands up, he switches very fast from “collision” to “no Collision” and back forever.

That´s really weird. He recognizes that he is in collision, as you can see in the textbox "in contact: 1), but the animations still loop from duck to stand.

I’ll come back to this tonight, as I am busy.
For now, though, I noticed that the part you put a question mark next to is in reverse order to my screenshot.
For whatever reason GDev does not like to play with the inverted “if point in object” condition. For now, make the events say:
[No condition]: Change the text of collision to “no collision”
if point in platform: Change the text of collision to “collision”

Toodles!

1 Like

OHHHH my god…

that´s it.

now it works. perfectly. that´s all.
and i tried something:
if i just switch the both, it works. No problems with the inverted condition. Again the issue was the order.

i now placed the inverted condition to the top and so the other as second, (can´t find the right words, screenshot comes).

insane!

Thank you so much! All the days the only thing i had to change was the order of these both. hehe. Doesn´t matter, i´m happy it works. Thank you very much!

1 Like