Hello!
Using Obi Rope, I'm trying to make a simple system where a rope is connected to a wall (attachment pin), and to an object that the player can control (another attachment pin); both of those static. I want to make sure that when the object moves away from the wall attachment, the rope gets longer, and when it gets closer, the rope gets shorter. I'm using a cursor, and I tried a few different solutions, but I couldn't get it to work. Here is the current code:
The result is extremely chaotic, as you can see in this video :
Am I missing something?
Also, along my experiences, I managed to make the rope shorter than zero, which results in an error spamming (in my opinion, it should not be possible), and also to crash Unity, probably by making it too long ? (I feel like there should also be a failsafe there).
Thank you!
Using Obi Rope, I'm trying to make a simple system where a rope is connected to a wall (attachment pin), and to an object that the player can control (another attachment pin); both of those static. I want to make sure that when the object moves away from the wall attachment, the rope gets longer, and when it gets closer, the rope gets shorter. I'm using a cursor, and I tried a few different solutions, but I couldn't get it to work. Here is the current code:
Code:
float dist = Vector3.Distance(obj.position, wallAttachment.position) * 1.2f;
if(dist - rope.restLength > 0.1f)
{
objCursor.ChangeLength(Time.deltaTime * ropeSpoolSpeed);
}
else if(dist - rope.restLength < -0.1f)
{
objCursor.ChangeLength(Time.deltaTime * -ropeSpoolSpeed);
}
The result is extremely chaotic, as you can see in this video :
Am I missing something?
Also, along my experiences, I managed to make the rope shorter than zero, which results in an error spamming (in my opinion, it should not be possible), and also to crash Unity, probably by making it too long ? (I feel like there should also be a failsafe there).
Thank you!