Need help with collisions

There’s a bug where you can go through the object going down and I don’t know why. Can anyone help? @CodeHelp @ShiningStars

Hopscotch

Bugged D-Pad by StarlightStudios

“Bugged D-Pad” by StarlightStudios. Made using the free Hopscotch app!

8 Likes

Ok so I think I found a solution because it works so far but I need to further test it so please keep this open

Edit: It’s works but objects that are touching each other might make the controls a little sticky but it’s fine

8 Likes

Ok ok new bug :bangbang:

If you are running into the wall and with another finger tapping a different part of the screen you go through the wall ://

Ok this wasn’t happening earlier but now you can just go through walls sometimes and you glitch when your in a corner…

5 Likes

something I found out is you can’t move up/down sometimes when going into a wall that should only stop your from going let/right and vice versa which idk why its happening

3 Likes

New bug: you can get stuck in the border of the wall and have to stay stuck there for eternity.

4 Likes

This bug has already been recorded, thanks though!

3 Likes

Ok so can anyone help… i hate being so persistent but idk what to do

3 Likes

I think it might help if maybe you could post specific screenshots of the collisions code, and mention what you want it to do

3 Likes

I mean I want it to not glitch and get stuck? The whole project is really the collision code, there’s barely anything that isn’t and since I don’t know the source of the problem I don’t know what to share

3 Likes

Instead of disabling movement in a certain direction with the is touching rule, you probably want to use rectangular collisions, and set the position of the character to either be above/below or left/right of the wall it’s colliding with when it’s colliding in a certain direction.

e.g. when colliding vertically, set position to above or below wall depending on player Y, and same with horizontal depending on X.

4 Likes

Thanks so much for showing me, I see that the colors change when the collide and I set the x position (of the penguin) to be left or right of the square when it’s colliding with it but it flickers instead

Sorry if I’m just not understanding this well

2 Likes

if the screen doesn’t shake as a result, then it’s fine that the rule occurs every other frame.

If you want to fix it, you’ll need to reorder the rules so that the player sets position before the collision check occurs

2 Likes

I’m kinda confused on what you mean?
This is the code I did that flickers

1 Like


The set position needs to run every frame, so put that if else block in a new rule, where the outer condition (labeled ‘rule conditional’) is the when rule. (The set color would not be in the new rule)

Thus, the code would be more like this:

3 Likes

im not a pro at how hopscotch execute code, but it seems like

Check if {
  Check if { // immediate check if else after the big check if (no set color block)
  } else {
  }
}

will run the whole in one frame (at least from what ive seen in my and other’s platformers

2 Likes

It didn’t work so I’m assuming I did it wrong, but here’s what I did (check the set pos to last touch code)

2 Likes

remove all set color blocks and youre done - its not wiggly anymore
btw, i believe you havent coded the top/bottom collisions right? top/bottom sends you to left/right

2 Likes

Thanks, but then it gets stuck and can’t move after it collides?

Also how would I fix the up/down issue then? Do you know? I had a similar issue with the joystick actually (og project)

2 Likes

because when the variable “collide” is set to 1, it prevents you from moving the character. basically when it gets stuck, it gets stuck forever

i see youve added code for left right collision, now you need to add the code for up down detection and up down set position

i suggest you to refer to spy guy’s collision if it helps

ill go check the joystick project now

2 Likes

The joystick project is the project that I needed to get fixed, so that would help a lot. Especially since I don’t know how I could adapt the dragging collision to the controller because they are pretty different?

2 Likes