# How to eliminate the vibration?

Hello
I have a question which is related with Unity Physics.
This is not a physics problem honestly.
I simulated a physics mechanism for me cells of personal project.
This is all about geometry and math and time and delta time.
So they do not have any built in Unity Physics and Collisions and Rigidbody at all. Therefore it is impossible to have the benefit of Unity built in physics such as collision detection.

The following is the logic what I have implemented.
So, if one cell is inside of radius of another cell, they should be pushed to outside of radius each other. I think this is a clear logic.
So, based on the positions and radiuses of cells, I calculated the displacement vector value that each cell should be displaced when they are inside of radius each other.

Everything was perfect except for the frame rate.
The problem is the frame rate should be infinity in this case theoretically.
In real life, the Rigidbodies can not be inside of each other.
This is because the reaction force is affect the Rigidbodies in real time.

I can not make the frame rate to be infinity.
Because of this, an vibrating effect is occurred.
At [N] th frame, a cell pushed to the north and at [N+1] th frame, a cell pushed to the south, when the cell is in middle of two other cells.
[N+2] th, to the north, [N+3] th, to the south.
This is the vibrating.

I have to eliminate this vibration from my cell.
I have attached to the code part I implemented and a video which is showing the terrible vibrating.
Thank you.

``````if (aBubbleNumber == (short)(cCellSlotIndex / EntityManager.PIECE_COUNT))// when cells are siblings
{
if (aCellModel.qCellCoolDown < 0.0f && cCellModel.qCellCoolDown < 0.0f)// when one cell can consum the other cell
{
if (aCellModel.mCellMass > cCellModel.mCellMass)
{
if ((aCellModel.mCellLocalPosition - cCellModel.mCellLocalPosition).sqrMagnitude < aCellModel.nCellRadiusSquared)
{
cCellModel.Change_CellActive(false);

aCellModel.Change_CellMass(aCellModel.mCellMass + cCellModel.mCellMass);
}
}
}
else// when one cell can not consum the other cell, they should be pushed each other
{
float distance = (aCellModel.mCellLocalPosition - cCellModel.mCellLocalPosition).magnitude;

float magnitude = (aCellModel.nCellRadius + cCellModel.nCellRadius - distance) / (aCellModel.mCellMass + cCellModel.mCellMass) * cCellModel.mCellMass;
Vector2 displacement = Vector2.ClampMagnitude((aCellModel.mCellLocalPosition - cCellModel.mCellLocalPosition), magnitude);

aCellModel.Change_CellLocalPosition(aCellModel.mCellLocalPosition + displacement);
}
}
``````

have you checked that (short)(cCellSlotIndex / EntityManager.PIECE_COUNT) is producing the numbers you expect?
Perhaps print them out to be certain.

The part you pointed is working correctly.
They detect that they are siblings or not.

I think there is a kind of misunderstanding due to my bad description.
What I meant was the vibrations between siblings.
This comes from fact that they are not real Rigidbodies.
I have experimented with Rigidbodies and there wasn't this kind of vibration.
However, Rigidbodies cannot be used because they cannot overlap each other when they should.

The only problem is the vibration.
I tried some solutions but did not work.
Could you help me?

hand-made is find :). I would need to look at/run the whole program, and the numbers being generated to work out what is happening. Also, I noticed in the video, the grid lines tend to break up and some disappear and reappear.