"Pixel perfect" Collision options

I have made a few collision options including “pixel perfect” collision! well… with four options and a short game that is…

Options:

  1. hitTest()
    1. Current: No math at all, Simple, Bad: Clip (platform top side only)
    2. Optimized: A bit of math, Bad: a bit of clipping (platform top side only)
  2. Hard Coded
    1. Hard Coded: MATH, NO CLIPPING, Takes velocity into account (platform top side only)
    2. Tileable: Hard Coded + Tileable, well… TILEABLE and a bit more math (ALL SIDE)

BONUS!!! SCROLLABLE SIMPLE PLATFORMER!!! With the hard coded tileable option (Belowww)
Revon's%20Collision%20Options

Revon’s colision options.html (1.9 MB)
Revon’s colision options1-15-2020_10-14-37AM.wick (14.3 KB) Tested in wick 1.16.1

4 Likes

This is really neat!

How do you code the ball to have a good collision?

I’ll simplify it… by a lot.

A ghost of the player (the velocity) if it is going through the platform the player is then set on the surface of the platform.

Visual: (there was never a ghost player, but only the velocity coordinate. this purple ghost player IS the velocity coordinate, visualized)
visual%20velocity%20coordinate

Dats smart… but if you go to the left wall and press right just before hitting the wall, do you clip into the wall?

Ive also managed to double jump on the wall surface sometimes…

And can i try to implement this myself into my own games?

I don’t think you can.
Double jump, it is possible, but you gotta be precise when pressing the jump button.
Yes, you can use this in your games.

Ok, thanks. Hopefully I can code it myself…

This is really cool! I think @zrispo and @Luxapodular would find this useful in improving the built-in hitTest() function. Good job!
I found a couple of quirks, though. On frame 5, if you press right to touch the wall and then jump, you will “float” on the raised platform. You’ll be unable to go right, only left.
image
I don’t know what causes the circle to get stuck, but the “floating” is caused because the hard-coded collision shape is internally a square, not a circle.

Maybe hitboxes could be actually implemented into the interface (like Construct 2) so you can easily edit them.
One way to implement this would be to add a “Collision” section to the inspector for Clips, where you can choose a collision shape and size (circle, rectangle, etc.), then you’ll see it as a colored shape in the middle of your Clip that you can drag to resize/move. There could also be a “Solid” checkbox that determines whether other objects with collision can pass through it. That way, this functionality can be automatic.

2 Likes

It is indeed hard coded with a square hit box. so if it is a circle object it will float. if it was a circle I think it will have more math that I don’t know formula of or… get every single coordinate point on the object velocity itself and test all of that if it hit a platform.