04-08-2022, 10:58 PM
(This post was last modified: 04-08-2022, 11:16 PM by landosilva.)
Hi! I've bought Obi Rope some years ago but only now I'm getting my hands on it, and I’m having some issues. I will list them below.
Thanks!
- How to set rope start and end position?
I’m spawning ropes at runtime and I felt like the documentation and tutorials are missing some examples on this.
What I was trying to do is to link the rope in two dynamic objects that has physics. So the attachment works but the rope is misplaced. I can’t figure out how to set the initial position of the rope’s start and end reliably. Here's the code:
public void Connect(Transform origin, Transform end)
{
_attachment1.target = origin;
_attachment2.target = end;
}
public void SetStartPosition(Vector3 position)
{
int firstParticle = _rope.elements[0].particle1;
_rope.solver.positions[firstParticle] = position;
}
public void SetLastPosition(Vector3 position)
{
int lastParticle = _rope.elements[^1].particle2;
_rope.solver.positions[lastParticle] = position;
}
So basically, I'm spawning a rope inside an existing Solver in the Scene, calling "SetStartPosition", "SetLastPosition" and "Connect" in sequence. It seems to work only right after spawning. If I need to change the link to some other object I can't set the position again it seems.
- Rope is too stretchy. How to handle that?
I don’t want my rope to stretch too much when moving my objects. I saw in the docs that I can increase the amount of substeps in the fixed updater, or decrease Unity’s fixed timestep, but I don’t think I had good results. What am I missing?
- How to reset Rope to it’s rest position?
When I assign the rope to a new position (and when it works, see 1.) it seems to come with the motion from its original position, starting with a lot of movement already, and I don’t want that. How to stop the rope’s forces and return it to the rest state?
Tried this but didn't get good results:
private void StopRope()
{
foreach (int solverIndex in _rope.solverIndices)
{
_rope.solver.velocities[solverIndex] = Vector4.zero;
_rope.solver.externalForces[solverIndex] = Vector4.zero;
}
}
- Is it possible to make it influenced by Time.timeScale?
My game is changing Time.timeScale sometimes, but it doesn’t seem to affect ropes. There is a workaround?
- ArgumentOutOfRange ObiRopeCursor.cs:169
I get this error sometimes when changing ropes length at runtime.
Thanks!