Sorry if this thread somewhere was, i am bad english speaker. i am could not search solve my problem
I was trying create Tetrominoes with 3D and Physics. And i had so many problems.
i dont have a good way and just set up experiments.
my Figure => empty parent object with Rigidbody when parent has a child just a cube with now box collider(and was capsule, and tryed sphere) i have physics material with values =>friction and dynamic friction 1 Bounciness 0 Friction Combine Multiply Bounce combine minimum and i have floor with Rigidbody deffault parameters and same material but floor is Kinematic. And when heap is big and figure drops not horizontal or figrues start flip over and rotates if in this moment next figure airdrops they all start bounciness and blow up all heap. how to prevent this behavior
this script is call when my script Raycast on each block in figure checked colliders. Now when i place i destroy rigidbody and this way prevent my blocs for bounciness. but i need Physics. blocs must flip and moves if they has big angle or something. like a building tower.
public override void Placement(Vector3 pos)
{
placed = true;
rb.velocity = Vector3.zero;
Destroy(rb);
}
private void FixedUpdate()
{
if (!parent.placed)
{
p0 = new Vector3((bounds.size.x / 2f) - 0.2f, 0, 0) + transform.position;
p1 = new Vector3((-bounds.size.x / 2f) + 0.2f, 0, 0) + transform.position;
p2 = transform.position;
if (CheckPoint(p0, Vector3.down))
{
parent.Placement(p0);
}
if (CheckPoint(p1, Vector3.down))
{
parent.Placement(p1);
}
if (CheckPoint(p2, Vector3.down))
{
parent.Placement(p2);
}
}
}
private bool CheckPoint(Vector3 p, Vector3 direction)
{
if (!parent.placed)
{
RaycastHit hit;
if (Physics.Raycast(new Ray(p, direction), out hit, 1f, parent.currentLayer))
{
float dot = Vector3.Dot(direction, hit.normal);
if (hit.distance <= 0.6 && dot >= -1 && dot <= -0.9)
{
Debug.Log("CURRENT POINT " + p + " dot product " + dot);
var rb = hit.transform.GetComponent<Rigidbody>();
rb.velocity = Vector3.zero;
}
return hit.distance <= 0.6 && dot >= -1 && dot <= -0.8;
}
}
return false;
}
I am very confused, if you remove the physical body, I will not be able to influence the blocks more accurately, but the blocks will not be able to influence other blocks. and I need them to behave like physical objects, but not explode and spring like psychos