|
|
Obi Rope Stretching with Attachment Problem |
Posted by: proxObi - 04-07-2023, 09:26 AM - Forum: Obi Rope
- Replies (2)
|
 |
Hi I have 2 particle attachment for my rope. First one for head of rope to set it to a station, other one for lets say a machine. When I take the machine I simply making the machine a child of my character and I can extend and move the rope automatically. However, as I use particle renderer, I can see that the particle seems same and not increasing with the size of rope as I can move further from the station. Lets say in the beginning I have 4 particle that I can see via the particle renderer, after the extending it seems same amount and it is 4. It makes the simulation look bad. I can fix it with making the ropes initial length bigger but I want a real solution for that. I also tried obi rope cursor but it doesnt work because of attachment I think. Thanks in advance.
|
|
|
grabbing rope and holding on to it |
Posted by: lbouis - 29-06-2023, 01:42 AM - Forum: Obi Rope
- Replies (2)
|
 |
Hi,
I am working on a VR game, I want my player hands to grab a rope with one hand and swing on it.
But I ran into some issues, essentially the player is able to grab the rope initially, but I not able to get my player to hold on to the rope when he moves (he is able to move very far away from the rope after grabbing it, but the shape of the rope looks good though).
I want the rope constrain his move once it's grabbed, I don't want the rope to strech much.
Note that I don't have a ton of experience with Unity (apologies in advance for any basic question). But I did some research, including this useful thread http://obi.virtualmethodstudio.com/forum...-2907.html.
So far I got the grabbing part partially working by:
1- Modifying the ObiContactGrabber slightly to create an attachment to the right hand game object when the player is able to grab the rope (instead of setting the grabbed particle inverse mass to 0).
I set the attachment type to dynamic. Otherwise the rope seemed to strech to the infinite when I tested (my understanding is that I need 2 way coupling).
2- adding ObiCollider and ObiRigidBody script to the hand game object.
Initially ObiRigidBody and RigidBody have kinematic (and kinematic for particles) set to true (otherwise I wasn't able to grab the rope, not sure why yet, I need to research it still)
When the particle is grabbed my script sets kinematic to false on the RigidBody and ObiRigidBody. That way the rope does not strech much when I move the player (and its hand).
The code run when grabbing the particle is successful looks like:
Code: var solver = particle.solver;
var actor = solver.particleToActor[particle.index].actor;
var group = ScriptableObject.CreateInstance<ObiParticleGroup>();
group.particleIndices.Add(particle.index); // index of the particle in the actor
handAttachment = rope.AddComponent<ObiParticleAttachment>();
//player transform is the right hand transform here
handAttachment.target = playerTransform;
handAttachment.particleGroup = group;
handAttachment.attachmentType = ObiParticleAttachment.AttachmentType.Dynamic;
//this was needed so the rope doesn't stretch indefinitely when player moves far away from it
// setting kinematic to false for the hand rigidBody
ObiRigidbody orb = playerTransform.GetComponent<ObiRigidbody>();
orb.kinematicForParticles = false;
Rigidbody rb = playerTransform.GetComponent<Rigidbody>();
rb.isKinematic = false;
Note that I am using continuous locomotion in VR to move the player (all based on UnityXR, XRInteraction toolkit).
So my current issue is that when the player grabs the rope then moves far from it, the shape of the rope looks good (doesn't stretch) but the player can still move very far.
But I want the player's hand to be stuck to the rope particle.
The concept seems to work with dynamic attachment in general (I was able to get a simple pendulum working).
So I suspect this is an issue related to logical conflicts between VR player locomotion and the Obi solver logics. I need the rope to 'pull back' the hand when it goes too far.
Any suggestion on how I can get this implemented?
I could probably figure out some scripting logic to force repositioning the hand (and player) close to the particle in one of the unity update() methods but not sure if I will succeed, and I was hoping for a simpler solution.
Eventually I want my player to be able to swing on the rope when he jumps (so hand and player stuck on the rope and no infinite rope stretching is definitely important). Not surehow/ if this will impact the solution.
Thanks in advance for the help.
|
|
|
Setting exact cable lengths and getting cable forces |
Posted by: rohit_dhak - 26-06-2023, 05:57 AM - Forum: Obi Rope
- Replies (1)
|
 |
Hello,
I have 3 questions I would like to get clarified.
1 - Setting exact cable lengths
In one of my earlier questions you mentioned that,
"The actual -calculated- length of a rope always strives to be its rest length, so this is the intended result: in your case, c2_len will strive to be as close as possible to restLength.
Imagine you have a rope that's 5 meters long at rest (under no forces). Then you hang a heavy object from it, and the rope stretches to be 5.2 meters long. Its restLength is still 5, but CalculatedLength() would return 5.2.
If you now call cursor.ChangeLength(6), the rope's restLength is set to 6, but due to the force applied by the object hanging from it its CalculatedLength() might be 6.2 (or 6.5, 7, 8.2... depending on how many substeps are used and how compliant the rope is).
This is usually useful to calculate strain (deformation due to forces), which is the ratio between the calculated length and the rest length."
If I have a load attached to 4 cables as shown in the scene.
And If i give control inputs to the cables as [28, 28, 28, 28] where the inutial cable lengths at the start are [25, 25, 25, 25].
I would like to have the cable lengths to be exactly [28, 28, 28, 28] but at the moment I get something like [27.830832 27.834806 27.824314 27.820284]
And If i change the cable lengths again to [25, 25, 30, 30] the results induced more offset from the applied control input and I get [25.510212 25.506298 29.991457 29.995811].
Currently I have 100 substeps for the solver.
Would it be logical to set cable lengths until the rest lengths attain the applied control , because at the moment I am applying the control until the current length reaches the applied control
Code: public Action SetCable1(float length, float control_ip, float velocity)
{
float c1_control_ip = control_ip;
float c1_len = length;
float c1_vel = velocity;
return () =>
{
if (c1_len > c1_control_ip + cable_threshold)
{
cursor1.ChangeLength(c1_len - c1_vel * time_dt);
}
else if (c1_len < c1_control_ip - cable_threshold)
{
cursor1.ChangeLength(c1_len + c1_vel * time_dt);
}
else if (c1_len == c1_control_ip - cable_threshold)
{
Debug.Log("Current Length and Control input are the same for Cable 1");
return;
}
};
}
I just want to know if there is a way to set the exact cable lengths I give as control inputs.
2 - Getting Cable Forces
Also I would like to know if there is a way in Obi rope to get cable forces at the points where the cables are attached to the load object (or ideally at different points of the cables)?
3 - Controlling the attached load object
Is it possible in Obi rope to moved the attached load and the cables just extend according to the load position?
Like inverse kinematics.
Any suggestions/ advice or clarifications are greatly appreciated.
Thank You.
|
|
|
RESET Obi Softbody |
Posted by: swancollective - 22-06-2023, 08:25 PM - Forum: Obi Softbody
- Replies (11)
|
 |
I need to reset the particles to their initial state after e.g. AR tracking is lost.
If I call "ObiSoftbody.ResetParticles", nothing happens.
How can I achieve this?
Thanks!
|
|
|
|