- Home /
How best to make long pipes/cables in unity?
Hi,
I am working on an educational game that allows museum visitors to explore various undersea environments. One of these environments is the undersea portion of an oil rig.
I have or can create models representing the various undersea well heads and components, and these are easy to place into a unity terrain, but I need to connect them to long pipelines that eventually lead up to the surface. I am trying to figure out the best way to do this. These are big heavy pipes, so they don't really need any physics to them. Colliders would be nice, but not absolutely necessary.
From my searches it seems like the best way to do this, may be a line or tube renderer: http://www.unifycommunity.com/wiki/index.php?title=TubeRenderer
Unfortunately, both of these require very large arrays of vector3s which I can't find an easy way to create. I would like to be able to draw a smooth vector spline into 3d space, and render it either as a shaded, or preferably a dimensional tube, and be able to tweak positioning in unity.
The other way, I guess would be to make the pipes all in a 3d program and import them in as meshes. This might be better, but it would be hard to precisely connect them to the other models in unity, and have them lie along the bottom of the unity terrain.
Any suggestions?
Thanks,
-Matt
Answer by Owen-Reynolds · May 12, 2011 at 01:06 AM
I'd go with the 3D modelling option. Just extrude a cylinder a whole lot, and give it bones with big, fat envelopes. Make the main bone be a short one on the bottom (the sea floor end,) where you want to bend them more, with longer ones near the top. No animation (or go ahead and make a few "swaying" clips.)
Twisting the bones (by hand, in SceneView/Inspector) will deform the object. I'm thinking if the bottom bone parents the rest, You can slap that right on your wellhead and tilt/animate the ones going up. They'll flap around at the top, but no one will be up there to see. If you want to hand-twist and animate, Additive animation mode might work.
You should be able to 3D model just one tube, and use different textures and scaling (in Unity) to reuse it for all the cables you need. If you need colliders, use the "compound" trick (one for each bone) and turn it into a prefab, to avoid the need to "collider up" each cable.
I absolutely agree. $$anonymous$$ake one straight piece of pipe and one that bends either 90 or 45 degrees. Then make use of unity's snap to matrix (hold control when placing) function to easily place them.
Sorry for the late reply. I got sidetracked on another project and then went on vacation, and forgot about this post. This sounds like the simplest solution, and one I didn't think of at all. I'm going to give it a try. Thanks much! -$$anonymous$$att
Answer by Joshua · May 12, 2011 at 02:23 AM
If you're a somewhat experienced programmer and if you have to set up a lot of these pipes you could create an editor script that lets you do what you want - draw a spline in space and create it along the line. Actually, that's what is so fantastic in Unity, if you need to do something more then twice: write an editor script to do it for you.
To be honest it actually sounds like a fun challenge. If you'd like some help you can contact me through the forums. ^.^
That's what I did for my rope system, its not hard to do. http://forum.unity3d.com/threads/83330-Procedural-Rope-System
Whow, that's a great looking end result. $$anonymous$$aking a non-moving pipe would be a lot easier though, I assume ;) would you be willing to share the script that actually creates the rope? I'd love to check if out and see if I can learn something of it - I have far to little experience with creating procedural meshes.
You're right >.< I just stumpeled upon it and thought it might help, so posted it without checking :p but if he uses that all he needs is an editscript that allow him to easily create and assign Vector3 positions..
Hi Josh, Sorry for the late reply,
I'm still learning unity and Javascript, so this option sounded more complex. I'm going to try out Owen's boned cylinder solution but if for some reason that doesn't work out, I'll contact you.
PS. Cool rope simulation Chris! A bit more than I need at the moment, but it looks very cool.
Thanks all.
Answer by lil_billy · May 12, 2011 at 01:48 AM
so heres a possible idea which might be somewhat labor intensive and or might not work so in pipelines theres always that connection joint now you should already have your basic pipe with texture that you can make as long as you want
but heres what i suggest you make the large part of that joint then you give it 2 children these will be flat cylinders slightly wider than your pipes but smaller than its parent and there length should be just long enough to hide any angles caused by this next step
next create a script create an empty variable to assign your pipe to in the scene then get the transform of that object in the update
transform.LookAt(object);
-look at the scripting reference for a better description on how to do this
next put that script on the right cylinder then drag the pipe next to it into its variable slot then repeat for the left (DO not use colliders)
what you should be able to do at the end of this is lay pipes in at whatever angle you choose at the intersections of these pipes this joint should be placed its children should be assigned to the corresponding pipes next to them and their lengths should be just long enough to hide any angle caused by the connection
of course at the same time you could have just let the pipes intersect anyways since the player cant see the messy internal geometry, this just seems cleaner but colliders will destroy it
Your answer
Follow this Question
Related Questions
3D max spline animation to Unity 0 Answers
Extruding tube animation possible in Unity? 1 Answer
Generating a Flat Mesh from Spline/Bezier Curve? 1 Answer
leantween ltspline control points setup 0 Answers
Spline off center using iTween 2 Answers