01-04-2022, 07:12 AM
(This post was last modified: 01-04-2022, 07:17 AM by josemendez.)
(31-03-2022, 08:42 PM)Oxters Wrote: When you say that the friction constraints should be globally enabled, do you mean that I should apply the Obi Collider Material to all Obi Colliders? If so then I have done that so far, but if not could you elaborate please.
ObiSolvers have a "Constraints" foldout that contain global settings for all constraint types (including friction). You can adjust solving parameters there: amount of iterations, the order in which they're performed, and whether the constraints are enabled at all. See:
http://obi.virtualmethodstudio.com/manua...olver.html
(31-03-2022, 08:42 PM)Oxters Wrote: In the conveyor code you might notice I also use MovePosition and MoveRotation, but those are only called when the panels are re-initialized. So they're only called once at the start or when I modify the conveyor belt, otherwise the AddForce and AddTorque functions are used.
[...]
Just got to test out the panel runtime creation theory and it seems I have found the culprit. If I use a prefab instead things work just fine. I cannot create panels from scratch. I'm so glad I found it, thanks for pushing me in the right direction.
Your code looks fine to me, and using a prefab for the panels or not shouldn't matter at all. I suspect this has to do with the order in which Unity is calling FixedUpdate() for different objects. As you know, this order is undefined by default: Unity may call FixedUpdate() for Obi first, then your conveyor belt, or vice-versa.
Since you're using rigidbody.velocity as input to your CalculateRequiredForceForPosition() function, and this value is modified by Obi during its FixedUpdate(), this makes your force calculations order-dependent: you will get different results depending on whether Obi has run yet or not.
If my theory is correct, instantiating a prefab might trick Unity into reversing the call order (you can't rely on this!) Not 100% sure, but I'd try to explicitly set the execution order (in Unity's script execution order window) and see if that affects the outcome.