Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Test if rope is tense, and extend it in code
#2
(18-03-2018, 12:56 PM)usernameHed Wrote: Hello, i have a rope attached on 2 player. I want to test in c# if the rope is tense enougth, and if so, extend the rope (when the player it a button for exemple).

I have found in GrapplingHook the way to extend the rope, with [ObiRopeCursor].ChangeLength([ObiRope].RestLength +- value;
Now, how can I test if the rope is more or less tense ? I could test the distance maybe...

I just bougth Obi rope, please be explicit

[Image: ezgif-4-e6bff1cec6.gif]

Hi there,

You can calculate strain like this:

Code:
float strain = rope.CalculateLength()/rope.RestLength;

strain will be >1 if the rope is stretched, 1 if the rope has exactly its rest length, and < 1 if the rope is compressed.

To extend the rope, use the ObiCursor component as you just discovered. Just add it to the rope and call its ChangeLength(newLength) method. The "Crane" sample scene also uses it to extend/retract the crane, for instance.
Reply


Messages In This Thread
RE: Test if rope is tense, and extend it in code - by josemendez - 18-03-2018, 01:01 PM