Block falling down collision bug?

0 favourites
  • 9 posts
From the Asset Store
Match same tiles with each other as fast as you can and earn more score during a limited time!
  • I made it so that blocks fall down like in Tetris (Bullet behavior), and when they touch another block, it stops. But they sometimes get stuck in mid air or on other blocks for no reason and they even fall into each other for a few pixels.

    project file: ufile.io/cy64u (Logic happens in last line, event sheet = Main)

    Using a normal block:

    Using a new sprite to test if it actually works, and it does:

    The collisions look like that just to prevent that.

    What I tried:

    1. When I Create a new Sprite it all works fine

    2. When I clone the Block sprite and use that one, it still doesn't work

    Tagged:

  • By the looks of your collision rectangle you probably understand this but I will explain why grid aligned games can be awkward

    In a typical collision engine 2 objects touching counts as a collision, even if it's a rare occurrence that should be the case.

    Most movement behaviours work along the lines of "If I move here will I be colliding? No, okay then move me there. Otherwise, I'll stay here". So when you have two objects moving exactly next to each other ( such as in grid aligned games ) it will appear to the object that it's path is obstructed, even though their overlap is technically 0 they are still touching each other.

    Some things you might want to check are:

    - your blocks are positioned at integer spacing

    - your blocks have an integer size

    - your blocks are not rotated

    - your collision rect is slightly smaller than the block

    - the size of the texture for your block sprite is the same as your instances ( prevents resizing of your collision rect )

  • I did check it all even before posting and it doesn't make any difference, that's why I'm lost :/ I even disabled all the other events

  • I had a look at your project, the falling blocks have been rotated by 90 degrees. So the small gap you've given for collisions is actually on the top and bottom.

  • Why is it getting rotated? I've only been setting the angle of motion to 90 degrees and the bullet property set angle is off. I still can't get it to work.

  • I'm not sure why it's being rotated, but if you check the properties of the spawned block objects in the debugger they are at a 90 degree angle. I discovered this when I decreased the collision box considerably, which caused a lot of overlap in stack blocks. So I fudged it by changing the collision rectangle to 0.1 - 31.9 in both dimensions instead of just X, which fixed the issue.

    It makes more sense to fix the rotation though, as you'll end up with you texture the wrong way round.

    You may want to try disabling the bullet behaviour ( perf boost ) and clamping the object position to the grid ( prevent visible block height variation ) when the collision happens.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Did change the collision rectangle to 0.1 - 31.9 too while double checking your listed causes, but nothing changed for me. I'll fix it eventually. Thanks for all the help Nepeo!

  • Hiya, I think it's because the reference instance it uses is in the 02 Mercy Please layout. I seem to recall it picks the level 0 so first in the list of layouts on the side 02 Mercy Please is the first layout. If you select all instances of block in 02 Mercy Please and disable Set Angle then it works, it's using the instances in there to set the angle to the angle of motion. Also to note you do have a mix of set angle enabled/disabled in the World layout however it's not referencing these for creating that block, setting these to Set Angle off still produces the issue because it's using a block instance somewhere in 02 layout.

  • Oh wow, don't know how you managed to find that out, so respect for that. Didn't have time today yet, I'll take a look now. Thanks!!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)