Help colliding rhombuses (SOLVED)

Jihl

Member
Hey there,

I'd like to use place_meeting with an object who's got a rhombus as a collision mask

1607026138865.png


But for some reason it doesn't take the collision with the perfect shape

1607026128204.png
1607026146218.png



the red one means it's colliding, and the second says it's not colliding
and here's the simple code I have for the object


GML:
/// step event
if (place_meeting(x, y, o_building)) {
    can_be_built = false;
}
else {
    can_be_built = true;
}
 
Last edited:

TheouAegis

Member
Do you have precise collision checking enabled? anything that is not a square needs to have precise collision checking enabled. If you do, and I can't remember if this is the case or not, then that would mean place_meeting() doesn't work with precise collisions, in which case you would need to use an actual collision event. Or you use a mathematical algorithm, but I don't have any of those off the top my head.
 

Roldy

Member
What version of GMS are you using?

What are the collision settings?

  • Mode: Manual
  • Type: Diamond (Slow)
What is the size of the image?
What is the bounds of the Diamond?

My initial guess is that the collision shape is larger than the bounding box of the sprite. And internally it is testing the BBox first, and if that isn't colliding than it just skips the collision mask. i.e. the collision mask needs to be smaller than the image size. But that is just a guess.

One to solve this is make an additional sprite (can be blank) that uses your collision mask but is also larger than your visible sprite.

e.g.
  • Your visible sprite is 64x64: Sprite1
  • Make a sprite that is 128x128: Sprite2
  • Sprite2 uses the diamond collision mask
  • In the objects that use Sprite1, set the collision mask instead of 'same as sprite' choose the larger Sprite2
  • You could have many different 64x64 images used for isometric tiles and they can all use Sprite2 for their collision mask
 
Last edited:

Jihl

Member
What version of GMS are you using?

What are the collision settings?

  • Mode: Manual
  • Type: Diamond (Slow)
What is the size of the image?
What is the bounds of the Diamond?

My initial guess is that the collision shape is larger than the bounding box of the sprite. And internally it is testing the BBox first, and if that isn't colliding than it just skips the collision mask. i.e. the collision mask needs to be smaller than the image size. But that is just a guess.

One to solve this is make an additional sprite (can be blank) that uses your collision mask but is also larger than your visible sprite.

e.g.
  • Your visible sprite is 64x64: Sprite1
  • Make a sprite that is 128x128: Sprite2
  • Sprite2 uses the diamond collision mask
  • In the objects that use Sprite1, set the collision mask instead of 'same as sprite' choose the larger Sprite2
  • You could have many different 64x64 images used for isometric tiles and they can all use Sprite2 for their collision mask
Thank you! That was it, My mistake was pretty simple to solve, sorry!


Do you have precise collision checking enabled? anything that is not a square needs to have precise collision checking enabled. If you do, and I can't remember if this is the case or not, then that would mean place_meeting() doesn't work with precise collisions, in which case you would need to use an actual collision event. Or you use a mathematical algorithm, but I don't have any of those off the top my head.
the mask collision was set to rhombus, you meant to have precise collision as the mask? The sprite wasnt a rhombus so I needed the rhombus mask to work hehe
 
Top