So I was playing around with hardoncollider the other day, and I found this weird issue. With two shapes colliding, everything works beautifully. But whenever I add a third shape, even if it's nowhere near the other two, the collision goes crazy, with shapes getting caught in each other.
I'm thinking that it has something to do with the separating vector, but I'm not really sure how that works.
I've uploaded a .love. If you move the smaller circle into the square, you should see it get caught. (Although, I've noticed it only does it like 2/3rds of the time )
If you go into the code, you can comment out the two lines that create the extra shape, and see the collision go back to working perfectly.
Any ideas?
Hardoncollider goes crazy with third shape
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Hardoncollider goes crazy with third shape
- Attachments
-
- hardon_problem.love
- Hardoncollider object getting stuck.
- (18.91 KiB) Downloaded 138 times
Re: Hardoncollider goes crazy with third shape
The separation vector always points in the direction shape_a has to be moved to resolve the collision, so you have to flip it if player is shape_b instead of shape_a. I.e. `on_collision()' should look like this:
Unrelated, but it bugs me: In `player_collide_with_post()', the two move calls should be combined into just one.
Code: Select all
function on_collision(dt, shape_a, shape_b, mtv_x, mtv_y)
if shape_a == player_bounding_box then
player_collide_with_post(shape_a, mtv_x, mtv_y)
elseif shape_b == player_bounding_box then
player_collide_with_post(shape_b, -mtv_x, -mtv_y) --< vector flipped
end
end
Re: Hardoncollider goes crazy with third shape
haha argh that makes so much sense. thanks man
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot], slime and 1 guest