Collision detection in hopscotch


#1

i’m working on geometry dash in hopscotch.
the problem is, 75% of the time, collisions don’t work.


what’s supposed to happen is that if the player hits the block and it’s not on top, the player dies.
otherwise, the player stays on the cube.
i’ve seen bugs like cubes not killing player, and even the player even sinking down into the blocks.
also, if you want to help but don’t have the subscription, you can delete images by holding down an image from the object select menu and then tapping delete.


#2

I have a similar problem where the characters don’t detect that they have hit each other most of the time so I had to give up on the project because it would have been impossible to make it work with the bug. I don’t have the subscription but it’s happing to my text sprites. Hope someone finds a solution on this topic!


#3

Please don’t report these bugs
This was detoured about 6 months ago
@DMF made this detour topic and it’s really useful

Thanks


#4

Collisions have never worked perfectly, I don’t know if they ever will


#5

i am using DMF’s collision method. i just need help so that the player won’t sink into the blocks, and also crashing into blocks works properly.


#6

Hi @claw33

Let’s move this to Debug My Code. And maybe make the original post clearer that that problem isn’t with Hopscotch collision rules (Bump or Touch) but rather with the project’s code for collision detection. I looked at the code and noticed that, but you’ll be more likely to get assistance by clarifying the problem.


#7

the problem is that collisions are not working.
when the player is close to the block but not on top:
reset level

when player is close to block and is on top:
stop the player from falling

this doesn’t work.
try running into the blocks at the beginning, won’t work.


#8

I’ll have a look to see if I can find the problem but it probably won’t be immediately. In the mean time, maybe someone else will have some suggestions…


#9

Absolutely no idea how, but changing self.y to self.y position(the default one) in where it gets the y distance between it and the cube seems to work


#10

nope, still won’t work.


#11


the player is behind the blocks, that’s the problem i’m having


#12

Huh.

It worked for me

#13

The player goes behind the block because of the logic circled below.

When the player is on the ground: 100 > 100 - 10 so it doesn’t set Done=2


#14


it only fixes half of the problem. but thanks!


#15

Yeah, it looks like that keeps happening


#16

True. You need different logic to distinguish between front & top side collisions.

Knowing where the problem lies, I thought you might like to find your own solution. I’m sure there’s multiple methods. Feel free to tag me later on if you try but aren’t able to work out a solution.


#17

i think i found a solution?
if the player’s y position is smaller than the block’s y position + 76, it will push the player up.
not the best method, but it kinda helps.


#18

i have no idea.
pushing the player up kinda helps, but it has tons more problems.


#19

Woah are you making geometry dash? You should see geometryscotch by valgo


#20

that makes the player die randomly