Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Prefab Creation & Cable Length with Rigidbodies
#1
Hello. I'm creating audio cables with physics and connectors for my XR project. Thanks for the amazing tool. 

I have  2 questions. 

1.  I already attached my rigidbodies on each end of the rope, but now I realize I need to make the rope longer.  How can I do that without needing to reposition and attach the precisely placed rigidbody cable connectors?

2. After I make my master cable which has the two connectors, how can I safely create a prefab that I can re-use over and over?  The cables I'm making also have custom snap functions that connect them to other gameobjects,  so it's important that both ends are able to be freely manipulated by the player in VR.  The goal here is to have different length & color coded prefab cables for the player to use.  With each level, I hope to be able to just drop them in the heirachy going forward.
Reply
#2
(01-05-2024, 10:21 AM)Sky d Wrote: 1.  I already attached my rigidbodies on each end of the rope, but now I realize I need to make the rope longer.  How can I do that without needing to reposition and attach the precisely placed rigidbody cable connectors?

Hi!

There's no need to reposition the ends of the rope or the objects it is attached to. Just edit your rope's path to make it longer. You may add new control points in between the ends of the rope and move them around, or change their tangent handles to elongate the rope.

Note this assumes you don't need the rope to be a straight line at rest, if you need it, you will need to reposition the cable connectors as well.

In case you need to create arbitrarily shaped cables connecting objects at runtime that might be at arbitrary positions/distances from each other, you might want to create your ropes entirely at runtime.

(01-05-2024, 10:21 AM)Sky d Wrote: 2. After I make my master cable which has the two connectors, how can I safely create a prefab that I can re-use over and over?  The cables I'm making also have custom snap functions that connect them to other gameobjects,  so it's important that both ends are able to be freely manipulated by the player in VR.  The goal here is to have different length & color coded prefab cables for the player to use.  With each level, I hope to be able to just drop them in the heirachy going forward.

Just creating a prefab the usual way should work. Just make sure that you instantiate your prefabs inside a ObiSolver at runtime, otherwise they won't be simulated or rendered.
Reply
#3
(01-05-2024, 10:43 AM)josemendez Wrote:
Quote:There's no need to reposition the ends of the rope or the objects it is attached to. Just edit your rope's path to make it longer. You may add new control points in between the ends of the rope and move them around, or change their tangent handles to elongate the rope.

Note this assumes you don't need the rope to be a straight line at rest, if you need it, you will need to reposition the cable connectors as well.

In case you need to create arbitrarily shaped cables connecting objects at runtime that might be at arbitrary positions/distances from each other, you might want to create your ropes ...
[url=http://obi.virtualmethodstudio.com/manual/6.3/scriptingactors.html][/url]

Thanks. I'll look deeper into this.

Quote:Just creating a prefab the usual way should work. Just make sure that you instantiate your prefabs inside a ObiSolver at runtime, otherwise they won't be simulated or rendered.

 Just to make sure I fully understand, do you mean I should place the end connectors as children under ObiSolver?  And then drag ObiSolver to the prefab folder?
Reply
#4
Quote:Just to make sure I fully understand, do you mean I should place the end connectors as children under ObiSolver? 

No, I meant that the rope itself must be a child (at any nesting level) of a ObiSolver. It's irrelevant whether the end connectors are or not, since they're regular rigidbodies and hence not simulated by Obi.

Quote:And then drag ObiSolver to the prefab folder?

What do you mean by this? there's no such thing as a specific "prefab folder" in Unity, you can have prefabs anywhere in your project. I just meant that when instantiating your rope prefab, you should make sure it's inside a solver's hierarchy.

For instance, if you have a solver in your scene that you want to simulate all your ropes, you just pass its transform as the parent. Something like:

Code:
var rope = GameObject.Instantiate(prefab, solver.transform);

let me know if you need further help. cheers!
Reply
#5
(01-05-2024, 11:54 AM)josemendez Wrote:
Quote:No, I meant that the rope itself must be a child (at any nesting level) of a ObiSolver. It's irrelevant whether the end connectors are or not, since they're regular rigidbodies and hence not simulated by Obi.


What do you mean by this? there's no such thing as a specific "prefab folder" in Unity, you can have prefabs anywhere in your project. I just meant that when instantiating your rope prefab, you should make sure it's inside a solver's hierarchy.

Sorry to cause any confusion.  I meant "my" prefab folder.   What I wanted to do was group together both my end connectors and the rope as one prefab.  Just like a real cable.  Since I will need sometimes 10 or more of these cables in a scene.  It would be amazing if I didn't need to keep reconfiguring the attachments -- if possible.  
Reply
#6
Quote:What I wanted to do was group together both my end connectors and the rope as one prefab.  Just like a real cable.  Since I will need sometimes 10 or more of these cables in a scene.  It would be amazing if I didn't need to keep reconfiguring the attachments -- if possible.

You can just make a prefab out of your rope+end connectors, this should work just fine. Obi ropes do not require any special prefab handing, they're just an object like any other.
Reply