15-04-2020, 12:46 PM
(This post was last modified: 15-04-2020, 12:51 PM by relevantname.)
(15-04-2020, 12:39 PM)josemendez Wrote: Hi,
It should have an effect. Are you using your own script to change the length of the rope? how does it look like?
Stretching is due to slow convergence, can be caused by insufficient constraint iterations and/or too large timestep (like in most physics engines). This is specially noticeable if the mass of the object attached to the rope is very large compared to the rope's mass.
So increase the amount of distance constraint iterations, and/or the amount of updater substeps. For more into on iterations/substeps and convergence, see:
http://obi.virtualmethodstudio.com/tutor...gence.html
You should change the mass if you feel like you need a heavier/lighter rope. It's up to you. Keep in mind that large mass ratios (very light/very heavy objects interacting together) slow down convergence, requiring to spend more resources to keep high quality results (iterations/substeps).
Hi, first of all thank you for your help. I solved the lenght problem. I have other questions in my mind though;
- Is there any difference between Handles and Pin Constraints?
- When I change the particle mass, the particles created in runtime are also have the same mass amount, right?
My code is;
Code:
_rope.RemoveFromSolver(null);
Quaternion lookRot =
Quaternion.LookRotation(_rope.transform.position - GameManager.Instance.Ball.transform.position, -Vector3.forward);
lookRot.x = 0.0f;
lookRot.y = 0.0f;
_rope.transform.rotation = lookRot;
_ropeRenderer.enabled = true;
Vector3 lastParticlePos = _rope.GetParticlePosition(_rope.UsedParticles - 1);
float distanceToBallFromHandle = Vector3.Distance(GameManager.Instance.Ball.transform.position, lastParticlePos) + _rope.CalculateLength();
float attachSpeed = GameManager.Instance.handleAttachSpeed;
_rope.AddToSolver(null);
while (_rope.CalculateLength() < distanceToBallFromHandle)
{
_ropeCursor.ChangeLength(_rope.RestLength + attachSpeed * Time.deltaTime);
yield return null;
}
_ropePinConstraints.RemoveFromSolver(null);
ObiPinConstraintBatch pinConstraintsBatch = _rope.PinConstraints.GetFirstBatch();
ObiDistanceConstraintBatch distanceContraintsBatch = _rope.DistanceConstraints.GetFirstBatch();
pinConstraintsBatch.AddConstraint(distanceContraintsBatch.springIndices[distanceContraintsBatch.springIndices.Count-1], GameManager.Instance.Ball.GetComponentInChildren<ObiColliderBase>(), Vector3.zero,
Quaternion.identity, 0);
_ropePinConstraints.AddToSolver(null);
_rope.AddToSolver(null);
Thanks again.