Collision detection in hopscotch


#21

Hi @claw33

Did you make any progress? It wasn’t easy but I was able to fix it. Do you want my version? I had to make quite a few changes. So it would take me a while to explain them.


#22

sure @ThinBuffalo


#23

Hi claw33, I’m still trying to fix something minor that’s bugging me. :laughing: Sorry bad pun. When the cube lands on the blocks it doesn’t always stop exactly on top. Sometimes it’s a few pixels below the tops.

One question. If the size of the blocks is 90 x 90 (in the collision rule [edit: I just tested them to be 86 x 86]), why did you use 76 as the pitch when setting the obstacles?


#24

got my calculations wrong .~.


#25

Hi @claw33

I finally got the updated version working the way I wanted. Well, at least good enough to share. Still a few things to do (noted in the project).

I added custom rules with some notes explaining things, but there’s more than I should explain to be complete. (I’ll add that later)

All the collision & cube control code was significantly simplified. I changed it so the variables canfall & falling aren’t needed. It only needs the Vertical velocity variable.

Set it positive and the cube jumps. The code is always subtracting from the velocity (you’ll notice the watch text jumps between 0 & -2). However other rules are continuously resetting the velocity to 0 when in the ground or on top of a block so it doesn’t fall. Rules & objects are in a specific order so this works right.

For the block collisions to determine if the cube is landing on the top or colliding with the side, the blocks check the angle between the cube and themselves.

If the angle is between 45 and 90, the cube is landing on the top. Otherwise (angles of 0 to 45), the cube is hitting the side. Actually, I had to use 42.5 to account for how much the block moves with each “step”, but in the perfect world it would be 45 degrees.

Edit: I drew the picture wrong. The black line defining the angle should be horizontal. :confounded:


#26

Any questions? I didn’t point out all of the changes above and wasn’t able to put notes on everything in the code.

Oh, I did move the springy block further to the left. The cube wasn’t clearing the 2 stacked blocks and just needed a bit more distance to gain height.


Do you want to work on the spike collisions? I may have an idea to improve those.


#27

yes


#28

I am unable to jump over the spikes… I die every time.


#29

Yeah, the spikes’ collisions are currently the same as the blocks (except you can’t land on them of course). Envision them as blocks when you time you jumps and you can clear them.

I assume Claw is going to work on the spikes’ collisions. But I’m not sure since I got a one word response to multiple questions and no response after fixing the block collisions and cube landing behavior.


#30


i’m using “is touching” for ze spikes and jump pads.
dis worke better


#31

Great. The only problem with Is Touching is it might cause lag, depending on how many clones there are.

You can try it and see.

Otherwise, just keep in mind that we can make a math rule similar to (x<86 and y<86) for the block, except it’d be a bit more complicated.


#32

https://c.gethopscotch.com/p/zz0ogkxtd My game is done after a long year!


#33

I guess you don’t need any help.
But if you still need, tag me! Or check my newest project:


#34

It has great collisions, so I think it should help! :smile: @claw33


#35

I found a little bug


When you die and then start again, you start rotating when you land on a cube


#36

Yeah idk how to fix. I have a version in my drafts that i think fixes it so ill use it for v2