Posts: 3
Threads: 1
Joined: Mar 2022
Reputation:
0
I have a conveyor belt set up where many panels are moving around in a loop using forces. They're basic box colliders and I added on them the obi collider component. I created a softbody object chips bag and tested it out, it bends and interacts with other objects nicely. But when it is on top of a panel, it does not move with the panel. I tried creating an obi collision material with high friction values and attaching it to both the panels and the chips bag, but that didn't work.
Frictionless Chips:
https://i.imgur.com/Eb8LOO7.mp4
Normal Behaviour:
https://i.imgur.com/kcZbQyY.mp4
Any help with this would be much appreciated.
Posts: 6,322
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
31-03-2022, 06:58 PM
(This post was last modified: 31-03-2022, 07:00 PM by josemendez.)
(31-03-2022, 05:52 PM)Oxters Wrote: I have a conveyor belt set up where many panels are moving around in a loop using forces. They're basic box colliders and I added on them the obi collider component. I created a softbody object chips bag and tested it out, it bends and interacts with other objects nicely. But when it is on top of a panel, it does not move with the panel. I tried creating an obi collision material with high friction values and attaching it to both the panels and the chips bag, but that didn't work.
Frictionless Chips:
https://i.imgur.com/Eb8LOO7.mp4
Normal Behaviour:
https://i.imgur.com/kcZbQyY.mp4
Any help with this would be much appreciated.
Hi!
How/when are you applying force to the conveyor belt panels? This should definitely work. There’s an example in the ObstacleRace sample scene, a rotating platform at the end you can stay on top of, relying purely on friction.
Also, make sure friction constraints are globally enabled in your ObiSolver component. (Kinda obvious but just in case! It’s easy to fall prey to that sort of thing)
Posts: 3
Threads: 1
Joined: Mar 2022
Reputation:
0
(31-03-2022, 06:58 PM)josemendez Wrote: Hi!
How/when are you applying force to the conveyor belt panels? This should definitely work. There’s an example in the ObstacleRace sample scene, a rotating platform at the end you can stay on top of, relying purely on friction.
Also, make sure friction constraints are globally enabled in your ObiSolver component. (Kinda obvious but just in case! It’s easy to fall prey to that sort of thing)
I'm relatively new to Obi (just bought the assets yesterday), so there's a high chance I missed something or forgot something. 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.
As for the how and when I'm applying forces to the belt panels, I do that during the fixed update call. Here's some code to show what I'm doing:
Conveyor -> https://pastebin.com/aqExDDMW
PhysicsHelperFunctions -> https://pastebin.com/nhajtU5E
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.
Posts: 3
Threads: 1
Joined: Mar 2022
Reputation:
0
31-03-2022, 10:39 PM
(This post was last modified: 31-03-2022, 11:06 PM by Oxters.)
(31-03-2022, 08:42 PM)Oxters Wrote: I'm relatively new to Obi (just bought the assets yesterday), so there's a high chance I missed something or forgot something. 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.
As for the how and when I'm applying forces to the belt panels, I do that during the fixed update call. Here's some code to show what I'm doing:
Conveyor -> https://pastebin.com/aqExDDMW
PhysicsHelperFunctions -> https://pastebin.com/nhajtU5E
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.
I took a look at your obstacle course scene. It's incredible, love it very much. I took one of the platforms and gave it the pole script that shifts it back and forth and the blob in the obstacle course moved with it just fine. In your script you directly set the velocity, so I thought maybe I should change my physics to use velocity. I switched it over and it still did not work. So I thought maybe it had something to do with how I've set up my softbodies/solver. To test I brought that same platform from the obstacle course into my scene, but the chips shifted with it just fine. I tried to change your code from setting velocity to using my forces, and the platform still worked fine with the chips softbody. I switch back to my conveyor as a sanity check and it still doesn't work. I can't seem to figure out what the issue is. My next guess is that it has to do with me creating the panels at runtime. I'll update again when I have more info.
(31-03-2022, 10:39 PM)Oxters Wrote: I took a look at your obstacle course scene. It's incredible, love it very much. I took one of the platforms and gave it the pole script that shifts it back and forth and the blob in the obstacle course moved with it just fine. In your script you directly set the velocity, so I thought maybe I should change my physics to use velocity. I switched it over and it still did not work. So I thought maybe it had something to do with how I've set up my softbodies/solver. To test I brought that same platform from the obstacle course into my scene, but the chips shifted with it just fine. I tried to change your code from setting velocity to using my forces, and the platform still worked fine with the chips softbody. I switch back to my conveyor as a sanity check and it still doesn't work. I can't seem to figure out what the issue is. My next guess is that it has to do with me creating the panels at runtime. I'll update again when I have more info.
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.
Posts: 6,322
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
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.
|