Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Limit GameObject Movement with Rope
#1
Hello,
I started using Obi, it's a great tool however I found difficulties when trying to set up Obi Rope.

Here's the first question that i wanted to ask.

- Is it possible to use Obi Rope to limit movement of game object?
I tried Chain example and from the editor tried to pull the object but it seems like it can't be tested like that. This is what I wanted to achieve, i wanted to test to tie a dog, so a dog will try to chase you but the dog movement will be limited to the rope that tied to the dog.

I saw it's possible when adding rigidbody, however it creates a big shakes on the gameobject, is it possible if it's IsKinematic Rigidbody?
When using IsKinematic, the rope just getting longer following where the dog goes.
Reply
#2
(20-04-2021, 11:52 AM)gigass21 Wrote: Is it possible to use Obi Rope to limit movement of game object?
I tried Chain example and from the editor tried to pull the object but it seems like it can't be tested like that. This is what I wanted to achieve, i wanted to test to tie a dog, so a dog will try to chase you but the dog movement will be limited to the rope that tied to the dog.

Sure, just make sure the object you attach to the rope has a rigidbody component. Rigidbodies in unity have mass and velocity, and forces can be applied to them. Obi will apply forces to any object attached using a dynamic attachment, but it needs to be a rigidbody. You can see an example of this in the included WrapTheRope sample scene. Once the rope is fully extended, it will turn red and you won't be able to pull further: the rope applies a force to the user-controlled sphere that prevents it from moving.




(20-04-2021, 11:52 AM)gigass21 Wrote: I saw it's possible when adding rigidbody, however it creates a big shakes on the gameobject, is it possible if it's IsKinematic Rigidbody?
When using IsKinematic, the rope just getting longer following where the dog goes.

A kinematic rigidbody has infinite mass. An object with infinite mass will push/pull all other objects around with infinite force, that's why the rope just follows the dog and does not oppose any resistance. Applying forces to a kinematic rigidbody has no effect.
Reply
#3
I see thank you for the explanation, it's clear now, but because the dog movement is using NavMesh, so it's not moved by Rigidbody, that's why the rigidbody is kinematic. So can we combine it and limit the movement with Rope?
Reply
#4
(21-04-2021, 08:31 AM)gigass21 Wrote: I see thank you for the explanation, it's clear now, but because the dog movement is using NavMesh, so it's not moved by Rigidbody, that's why the rigidbody is kinematic. So can we combine it and limit the movement with Rope?

You can't have physics (non-kinematic rigidbody) on a NavMesh agent, as far as I know. An object can be either governed by navigation or physics, not both at once.

Howeve you could have a navmesh agent, and a non-kinematic rigidbody that follows it. That way the rigidbody can be affected by forces: one force pulls it towards the navmesh agent position's, the other force is applied by the rope. When both forces even out, the rigidbody will no longer be able to move.
Reply
#5
I think i have an idea to validate to stop the movement through the script to check the length of the Rope.

I found this function, so it can't be more than a specified length. If the dog travels more than the length, i'll stop the chase.

Code:
obiRope.CalculateLength()

Does that the correct function to check the length?

I haven't tried this, but thank you for explaining. Sonrisa
Reply
#6
(21-04-2021, 11:49 AM)gigass21 Wrote: I think i have an idea to validate to stop the movement through the script to check the length of the Rope.

I found this function, so it can't be more than a specified length. If the dog travels more than the length, i'll stop the chase.

Code:
obiRope.CalculateLength()

Does that the correct function to check the length?

I haven't tried this, but thank you for explaining. Sonrisa

Yes, this function calculates the current rope length. Note this is different from the rest length, which is the length of the rope with no stretching/compression.

Both can be used to calculate strain, which is the ratio of current length to rest length. It will be <1 if the rope is compressed, ==1 if the rope remains at rest length, > 1 if the rope is stretched.

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