Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Some questions & requests
#2
Hi there!

(04-08-2022, 10:58 PM)landosilva Wrote: 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.

I assume your use case is to re-attach an existing rope to some other object, not creating a new rope between two points, correct? I ask this because re-attaching the rope will not change its rest length: if the two objects are further apart than the length of the rope, the rope will stretch.

Just tried your code, and it works fine for me. Setting the position of the particles and then setting the attachment targets is the correct way to do it. If it works right after instantiating the rope, I don't see any reason for it not to work later. Could you share a bit more about the context in which you're doing this?

Btw, the "scripting ropes" section of the manual has some sample code for getting the rope's start/end positions, setting them is basically the same, you just write into the solver.positions array instead of reading from it. This is what you already have in your code so I guess I'm being Captain Obvious ™Sonrisa
http://obi.virtualmethodstudio.com/manua...ropes.html


(04-08-2022, 10:58 PM)landosilva Wrote: 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?

With a few substeps (8-10 are usually more than enough) ropes should not stretch at all, unless:

- There's comparatively heavy objects attached to them (for instance, a 100 kg object hanging from a 10 grams rope). Iterative solvers have a hard time dealing with large mass ratios, so keep them low (1:10 max)

- Your attachments are static (as opposed to dynamic), or you're moving the objects by directly setting their transform.position. This will basically bypass physics, since ropes rely on applying forces to rigidbodies. If you use static attachments or set positions directly, objects will ignore forces and ropes will blindly follow the objects they're attached to, stretching if required.

(04-08-2022, 10:58 PM)landosilva Wrote: 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?

All actors have a Teleport(position, rotation) function. You can call that, or if you want to do it yourself you need to set the particle's previous positions and interpolated positions as well:

Code:
m_Solver.positions[solverIndex] = yourPosition;
m_Solver.prevPositions[solverIndex] = yourPosition;
m_Solver.renderablePositions[solverIndex] = yourPosition;

If you want to reset the particles to their starting position (the one set in the blueprint), you can also call ResetParticles().

(04-08-2022, 10:58 PM)landosilva Wrote: 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.

Obi uses Unity's FixedUpdate() by default, so it is affected by Time.timeScale. In fact there's a sample scene included (RopeAndJoints) that allows you to enter "bullet time" by enabling a checkbox, and it does this by setting Time.timeScale to 0.25 (see Obi/Samples/Common/SampleResources/Scripts/SlowmoToggler.cs)

(04-08-2022, 10:58 PM)landosilva Wrote: ArgumentOutOfRange ObiRopeCursor.cs:169
I get this error sometimes when changing ropes length at runtime.

I haven't received any similar reports, could you provide some steps to reproduce this? The line the error refers to looks like this:

Code:
m_CursorElement = rope.elements[Mathf.Max(0,index - 1)];

"index" is the element index where the cursor is located, and at least in theory it cannot be in a non-existent element.
Reply


Messages In This Thread
Some questions & requests - by landosilva - 04-08-2022, 10:58 PM
RE: Some questions & requests - by josemendez - 05-08-2022, 07:57 AM
RE: Some questions & requests - by landosilva - 05-08-2022, 03:34 PM
RE: Some questions & requests - by josemendez - 05-08-2022, 04:17 PM
RE: Some questions & requests - by landosilva - 06-08-2022, 02:59 PM
RE: Some questions & requests - by josemendez - 08-08-2022, 07:44 AM
RE: Some questions & requests - by landosilva - 08-08-2022, 09:46 AM
RE: Some questions & requests - by josemendez - 08-08-2022, 10:54 AM
RE: Some questions & requests - by landosilva - 08-08-2022, 02:09 PM
RE: Some questions & requests - by josemendez - 08-08-2022, 02:24 PM
RE: Some questions & requests - by landosilva - 08-08-2022, 02:56 PM
RE: Some questions & requests - by josemendez - 08-08-2022, 03:21 PM
RE: Some questions & requests - by landosilva - 08-08-2022, 03:44 PM
RE: Some questions & requests - by josemendez - 08-08-2022, 03:46 PM
RE: Some questions & requests - by landosilva - 09-08-2022, 04:51 PM
RE: Some questions & requests - by josemendez - 10-08-2022, 07:18 AM
RE: Some questions & requests - by landosilva - 10-08-2022, 10:03 AM
RE: Some questions & requests - by josemendez - 10-08-2022, 10:15 AM
RE: Some questions & requests - by josemendez - 10-08-2022, 10:39 AM