Hello guys. Attached below is a picture of what I want to do.
The question is how do I do this? Because I tried using Collision boxes with IsTrigger enabled:
// when TB starts to touch anything
void OnTriggerEnter(Collider Other)
{
Current_Collider = Other;
if (Other.collider.tag == "EndPoint")
{
TB_State = TetrisBabyState.Dead;
return;
}
if (Other.collider.tag != "Wall")
{
if (TB_State != TetrisBabyState.Walking)
{
TB_State = TetrisBabyState.Walking;
}
}
}
// when TB stops touching anything
void OnTriggerExit(Collider Other)
{
if (Other == Current_Collider)
{
TB_State = TetrisBabyState.Falling;
}
}
I also tried OnCollisionEnter:
void OnCollisionEnter(Collision Other)
{
//Debug.Log("( " + Other.contacts[0].point.x + ", " + Other.contacts[0].point.y + " )");
//Debug.Log("Hit " + Other.collider.name);
if (Other.collider.gameObject.tag == "Player")
{
}
Current_Collider = Other.collider;
if (TB_State != TetrisBabyState.Walking)
{
TB_State = TetrisBabyState.Walking;
}
}
void OnCollisionExit(Collision Other)
{
//Debug.Log("Unhit " + Other.collider.name);
// if this is the latest collider
if (Other.collider == Current_Collider)
{
if (TB_State == TetrisBabyState.Walking)
{
TB_State = TetrisBabyState.Falling;
}
}
}
and rigidbody.sweeptest too (code too messy not gonna post it here). I plan to redo this collision from the ground up so if anyone can give me a push in the right direction on how to go about doing this would be much appreciated. Thanks in advance.
EDIT: Oh i forgot to mention. If possible i do not want to use too much physics. I am moving the characters by transform. So minimal physics will be nice. Thanks ![]()

If you're using blocks where everything is in a grid, the simplest way is not to use physics/colliders at all, but use a 2D array to represent the world. Then you can just check the appropriate array entry.
– Eric5h5Instantiate returns Object in C#, so you have to cast it appropriately, but you can't instantiate a Transform as a GameObject anyway. (It would be easier to read your code if you follow the standard Unity convention of using lowercase for variable names, and uppercase for methods and classes.) However I wasn't referring to an array of GameObjects, I was referring to an array of something like ints or bytes. The array is supposed to represent the game world, not be the game world. See [here][1]. [1]: http://forum.unity3d.com/threads/5105-Gravity-3d-Tetris?p=38267&viewfull=1#post38267
– Eric5h5Also I saw your tetrisclone and it was not what I was really looking for. Really sorry for that but thanks for helping me. Really thankful for your help:)
– mh4