Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Solver is too performance heavy
#21
(16-06-2025, 07:30 AM)chenji Wrote: It'd be better if you could send some picture to clarify your requirement. It looks to me you can just use dynamic attachment, simply bind the person's hand to the rope (hand is using a joint to bind the person).

Hi Chenji,

Quent_1982's code contains logic to bind the person to an arbitrary point in the rope, not just the position of a particle. It's better to use a pinhole for this, since attachments can only attach to a specific particle in the rope, not any point in between particles.

He tried to create lots of control points along the rope to be able to do this, that's why my suggestion was to use a pinhole - as he can just specify a normalized coordinate along the rope which is simpler.

kind regards
Reply
#22
(13-06-2025, 02:52 PM)quent_1982 Wrote: Thanks for mentioned distance fields, I really somehow missed the article about them in docs, I've implement them and all obi collisions are working great now and maybe if I can to implement pinholes I'll be able to completely remove invisible rope and that's great!

None of the example scenes included with Obi use an invisible rope made of colliders, so you certainly can remove it Sonrisa.

(13-06-2025, 02:52 PM)quent_1982 Wrote: But I can not understand how pinholes is working and to what them are attaching to, because when I'm trying to attach some of player's hand or other limb the rope is aiming to reach player's mesh center and as a result there is a big gap between player and rope.

Pinholes attach a point along the rope (expressed as a normalized coordinate, 0 being the start of the rope and 1 being the end) to a position in an object, expressed in the object's local space. If the pinhole is aiming to reach the player's mesh center, it means you passed zero (Vector3.zero) as the position, which is the center of the object. This is what your original code using regular pin constraints does too.

You need to pass a proper local-space point instead. Keep in mind Unity has lots of methods to convert data between vector spaces, such as TransformPoint.

kind regards,
Reply
#23
(16-06-2025, 07:30 AM)chenji Wrote: It'd be better if you could send some picture to clarify your requirement. It looks to me you can just use dynamic attachment, simply bind the person's hand to the rope (hand is using a joint to bind the person).

Hello, I've already tried to use dynamic attachments, but they don't show good results to me, thanks.
Reply
#24
(16-06-2025, 08:41 AM)josemendez Wrote: None of the example scenes included with Obi use an invisible rope made of colliders, so you certainly can remove it Sonrisa.


Pinholes attach a point along the rope (expressed as a normalized coordinate, 0 being the start of the rope and 1 being the end) to a position in an object, expressed in the object's local space. If the pinhole is aiming to reach the player's mesh center, it means you passed zero (Vector3.zero) as the position, which is the center of the object. This is what your original code using regular pin constraints does too.

You need to pass a proper local-space point instead. Keep in mind Unity has lots of methods to convert data between vector spaces, such as TransformPoint.

kind regards,

Hello!

Thanks for guiding me through this from the scratch. I’ve implemented the grabbing system from the VineSample and it mostly works, but there’s still a big noticeable gap between the player’s hands and the rope when rotating (almost same gap as mentioned in my earlier posts). Is there a way to make the rope’s simplex(hope I've called it properly) follow the hand position exactly, without any gaps or sagging like in the VineSample?

Maybe player's hierarchy will help:

Player -> Rigidbody
---MainBone -> Nothing
------BodyBone -> Rigidbody, Joint, ObiRigidbody
----------MiddleHandsCollider -> Collider, ObiCollider <- it is the object that register collisions with obi, becomes trigger after grab and it's transform I set as a target of the pinhole.

Kind regards
Reply
#25
(16-06-2025, 12:06 PM)quent_1982 Wrote:  but there’s still a big noticeable gap between the player’s hands and the rope when rotating
I had similar question before when I tried to implemente a "a person hold a fishing rod&rope, and rotate the person" scenario. The difference is I'm using attachment instead of pinhole but I think it's similar. Basically you need to check below things:

  1. You'd better use AddTorque (physics related) to rotate anything, instead of changing GameObject's transform(only affect visual), if you want the rope's behavior close to real world one. 
  2. Try to use Synchronous Fixed mode https://obi.virtualmethodstudio.com/manu...eloop.html
  3. Try to add substeps of solver to see whether it's better
  4. Check Interpolation of your Rigidbody. Make sure they are same with Obi Solver.
  5. To inject world space angular inertia into the simulation set the solver's world space angular inertia to a non-zero value
  6. Check the Obi/rigidbody colliders of the conterpart of the problem. For example, if your problem is A and B has a gap, check whether A and B has collisions. Try disable their collision to see whether it works.
  7. You may manually align the position in every simulation step. Like below (though it breaks the physics simluation result, make sure it's suitable in your scenario, if you want to use this approach):
void Start()
{
  solver.OnInterpolate += RopeSolverInterpolate;
}

 private void RopeSolverInterpolate(ObiSolver solver, float timeToSimulate, float substepTime)
    {
       
        int firstParticle = rope.elements[0].particle1; //Get the particle you want to move
        solver.renderablePositions.SetVector3(firstParticle, solver.transform.InverseTransformPoint(TheObjectInYourScenario.transform.position));
    }
Reply
#26
(16-06-2025, 01:40 PM)chenji Wrote: I had similar question before when I tried to implemente a "a person hold a fishing rod&rope, and rotate the person" scenario. The difference is I'm using attachment instead of pinhole but I think it's similar. Basically you need to check below things:

  1. You'd better use AddTorque (physics related) to rotate anything, instead of changing GameObject's transform(only affect visual), if you want the rope's behavior close to real world one. 
  2. Try to use Synchronous Fixed mode https://obi.virtualmethodstudio.com/manu...eloop.html
  3. Try to add substeps of solver to see whether it's better
  4. Check Interpolation of your Rigidbody. Make sure they are same with Obi Solver.
  5. To inject world space angular inertia into the simulation set the solver's world space angular inertia to a non-zero value
  6. Check the Obi/rigidbody colliders of the conterpart of the problem. For example, if your problem is A and B has a gap, check whether A and B has collisions. Try disable their collision to see whether it works.
  7. You may manually align the position in every simulation step. Like below (though it breaks the physics simluation result, make sure it's suitable in your scenario, if you want to use this approach):
void Start()
{
  solver.OnInterpolate += RopeSolverInterpolate;
}

 private void RopeSolverInterpolate(ObiSolver solver, float timeToSimulate, float substepTime)
    {
       
        int firstParticle = rope.elements[0].particle1; //Get the particle you want to move
        solver.renderablePositions.SetVector3(firstParticle, solver.transform.InverseTransformPoint(TheObjectInYourScenario.transform.position));
    }

Thanks for suggestions, but I've already tried all stuff include yours, so to solve my case I need help from creator of this asset to delve deeper into my problem. 

Kind regards
Reply
#27
(16-06-2025, 12:06 PM)quent_1982 Wrote: ----------MiddleHandsCollider -> Collider, ObiCollider <- it is the object that register collisions with obi, becomes trigger after grab and it's transform I set as a target of the pinhole.

Hi,

If you're using a collider to register collisions against the rope, what's the point of converting it to a trigger *after* grabbing the rope? Isn't it better to just use a trigger to detect the collision?

(16-06-2025, 12:06 PM)quent_1982 Wrote: there’s still a big noticeable gap between the player’s hands and the rope when rotating (almost same gap as mentioned in my earlier posts).

How are you performing the rotation? Note that physics in Unity don't run every frame, so if you rotate the object by simply transform.Rotate or rotation = something in Update(), that will cause a gap. It's best to use torques as Chenji pointed out, since they are part of the physics simulation. This is what the Vine example does, as its character controller is fully physics based.

kind regards,
Reply
#28
Quote:If you're using a collider to register collisions against the rope, what's the point of converting it to a trigger *after* grabbing the rope? Isn't it better to just use a trigger to detect the collision?

Does it mean that I can read trigger events from ObiSolver.OnCollision event too? If that's true it will be great!

Quote:How are you performing the rotation? Note that physics in Unity don't run every frame, so if you rotate the object by simply transform.Rotate or rotation = something in Update(), that will cause a gap. It's best to use torques as Chenji pointed out, since they are part of the physics simulation. This is what the Vine example does, as its character controller is fully physics based.

I'm rotating player by default using AddTorque, I do not know why Chenji mentioned it, so it is still not clear why there is a gap and how to properly force rope to follow player's hands after succeseful grabbing.

Kind regards
Reply
#29
(16-06-2025, 06:44 PM)quent_1982 Wrote: I'm rotating player by default using AddTorque, I do not know why Chenji mentioned it
If you did then you can just ignore this checkpoint. How and where you rotate actually is important. Do you rotate in FixedUpdate? If not try to do that. If you rotate in a late stage, you'll probably also get 1-frame-gap issue. 

Also did you try my suggestion to manually change particle position in solver.OnInterpolate to keep rope follow player's hands? I think this should work as a last resort.
Reply
#30
(16-06-2025, 06:44 PM)quent_1982 Wrote: Does it mean that I can read trigger events from ObiSolver.OnCollision event too? If that's true it will be great!

Yes, triggers are also included in collision detection and ObiSolver.OnCollision will also report them. Contacts against triggers are simply ignored during collision response.

(16-06-2025, 06:44 PM)quent_1982 Wrote: I'm rotating player by default using AddTorque, I do not know why Chenji mentioned it, so it is still not clear why there is a gap and how to properly force rope to follow player's hands after succeseful grabbing.

There can be many reason for a gap to appear. Most of them have to do with how and when you're moving the character in relation to the simulation. Chenji's advice regarding this matter is solid, make sure to double check these points specifically:


*You'd better use AddTorque (physics related) to rotate anything, instead of changing GameObject's transform(only affect visual), if you want the rope's behavior close to real world one.
*Try to use Synchronous Fixed mode https://obi.virtualmethodstudio.com/manu...html*Check Interpolation of your Rigidbody. Make sure they are same with Obi Solver.
*Check the Obi/rigidbody colliders of the conterpart of the problem. For example, if your problem is A and B has a gap, check whether A and B has collisions. Try disable their collision to see whether it works.

kind regards,
Reply