01-04-2021, 09:57 AM
(This post was last modified: 02-04-2021, 03:36 AM by akayashi1212.)
(01-04-2021, 08:40 AM)josemendez Wrote: You can completely disable distance and bend constraints (either in the cloth, or the entire solver). That will allow particles to move independently of each other.
I got it, now i can moving the particles independently like you said. My code:
Code:
private void FixedUpdate()
{
if (Input.GetMouseButton(0))
{
Ray ray = cam.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, out hit, Mathf.Infinity, LayerSlime))
{
for (int i = 0; i < solver.positions.count; ++i)
{
if (Vector3.Distance(hit.point, solver.positions[i]) <= Radial)
{
solver.positions[i] += moveParticle(hit.point, solver.positions[i]); // move around with X and Z axis
//solver.positions[i] += new Vector4(0, -1f, 0, 0) * Radial / 10f; // move down with Y axis
}
}
}
}
}
Vector4 moveParticle(Vector4 center,Vector4 particle)
{
return (particle - center).normalized * Radial / 10f;
}
Then, the cloth (my slime) doesn't reforming. I must reform it manually by my code (move the particles to the old position) or have any idea?
My setting:
https://drive.google.com/file/d/1pAX0U23...sp=sharing
https://drive.google.com/file/d/1GCe2xA6...sp=sharing
How it goes when move around (X and Z axis):
https://drive.google.com/file/d/14qEC0Ou...sp=sharing
How it goes when move down (Y axis):
https://drive.google.com/file/d/1YOZKWsL...sp=sharing
sorry, i don't know insert picture
thank you!