Hello Guest

Author Topic: Colliding halfway through  (Read 2396 times)

DemiGoth

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 45
    • View Profile
Colliding halfway through
« on: November 11, 2013, 06:14:41 am »
I'm making my own variation on the old Tetris game and am now at the part where I can start on collision for the objects (falling block, frame and the blocks on the bottom). To do this I'm experimenting with the OnTriggerEnter() and the function only has one Debug.Log instruction to tell me it actually IS colliding. I do get the Debug.Log message in the console, but... The message appears when the Tetris block is already halfway through the bottom of the frame :(

How do I get actual collision of the Tetris blocks and the frame the moment they touch? For both I've made polygon collides around the edges of their textures, because this is where the collision has to occur.

Also worth to add is that the moment my game starts (and the Tetris object is floating top center and not touching anything) the collider is triggered...
« Last Edit: November 11, 2013, 06:46:53 am by DemiGoth »

DemiGoth

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 45
    • View Profile
Re: Colliding halfway through
« Reply #1 on: November 11, 2013, 08:13:26 am »
I figured out WHY this behavior is happening...

From what I've read here on these support forums, to make the collider to work, I have to toggle the convex in the mesh collider. But doing so, the polygon collider area (a U-shape where the Tetris blocks fall) is overruled and the whole texture thing becomes a collider itself.

I'd like to know how to get that polygon collider I made to work...

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Colliding halfway through
« Reply #2 on: November 11, 2013, 11:32:34 am »
If you're making a tetris game, I strongly recommend using primitive colliders - create your sprites with collider type set to Unset / User Defined, then create prefabs out of each sprite type. You can then manually attach the appropriate box colliders to create the shapes. Also, don't forget to add a rigid body to the sprite. You can then instantiate the prefabs as required.