• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
9
Question by h0stis · Jul 16, 2010 at 12:45 PM · physicsrope

How do you make ropes?

Hi, guys! So how do you make ropes? As far as I understand there is no "rope object" in Unity. I want to do the following: To make a crane with a rope, one end of the rope is attached to a cylinder and when the cylinder rotates it winds the rope onto itself making the hook go up, when it rotetes in the opposite direction it unwinds the rope making the hook go down. The derrick of the crane is also able to go up and down. On the end of the derrick there is anothe cylinder that is also interacts with the rope. I think I post a picture to visualize my words.-) I apologise for the quality of the picture, I'm not that good at Photoshop.So how do you make something like this:

Any suggestions?

P.S. I looked up this topic:

http://answers.unity3d.com/questions/2217/tie-objects-togethe

and the scripts are greate, but the rope doesn't interact with rigid bodies. Also I tried to use a skinned cylinder, but it also doesn't interact with rigid bodies.

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image meat5000 ♦ · Jan 04, 2018 at 01:42 PM 0
Share

Deleted answer by Jake 2 due to reports of links gone bad and now containing viruses due to domain shifting.

5 Replies

· Add your reply
  • Sort: 
avatar image
19

Answer by equalsequals · Jul 16, 2010 at 03:11 PM

If you want to make a physics rope, it will take several segments of rigid bodies attached by Joints. Currently your best bet would be the HingeJoint.

I recently worked on a Unity-powered game where we had a chain/rope-like string of objects that trailed behind the character and that was the class we used to tie those rigid bodies together.

I'm going to be honest, this is a pretty intricate task and there isn't really an easy way to implement this - especially the winding/unwinding functionality.

My personal advice is this - fake it as best you can. Unless the entire game is solely about the most realistic crane ever built, just fake it.

Judging by the bottom-left image (stick man "platforming" on the crane) Correct me if I am wrong, but I'm guessing that you are making a platformer of sorts.

When it comes to production you want to look at a cost-per-component ratio. You want the most important features, like your controls and other main game mechanics to have the most time/money invested. If something is rather minute in scope, insignificant in the grand scheme of things, investing so much time as to create absolute real-world physics is going to blow the cost/value of component ratio way out of proportion.

It's really up to you to decide how important any component of the game is, but a rule of thumb I use is how often any one component appears in the game. If you've got 1-2 cranes in a level - not so important. Again, if the crane is the entire game, essentially, disregard what I said, use the HingeJoint class, and I will eat my hat.

In the scenario where it should just be faked, I would do it using animations and coordinated/synced interpolated collision geometry to achieve a "good enough" product.

Sorry for the length, hope this helps.

==

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image h0stis · Jul 16, 2010 at 07:39 PM 0
Share

Thanks, equalsequals! I'll try the hinge joint thing. I want rope to be as realistic as possible. Because the level consists of a platform and two cranes, so the cranes(and ropes) are important.

avatar image BerggreenDK · Nov 29, 2010 at 03:38 AM 2
Share

But the top two green "wheels" + the rope between them, can be faked without ruining the actual game as I see it. Just make the "hinge joint" from the tip of the crane and down. Dont make the "roll around barrel" part with real simulation, just fake the look with animation or place the "wheel" inside a box so you can only see it going in through a hole.

avatar image
4

Answer by paste120 · Jul 16, 2010 at 06:24 PM

Physics rope could be created in Unity3 by using the new cloth system. Demo video: http://blogs.unity3d.com/2010/07/13/unity-3-feature-preview--cloth-physics/

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image h0stis · Jul 16, 2010 at 07:42 PM 0
Share

Wow! Very cool feature! But unfortunatly there is not unity3 yet, only beta for the ones who pre-ordered the product. I use indie version.

avatar image paste120 · Jul 17, 2010 at 06:50 AM 0
Share

Ya, I'm sorry. I've upgraded and have access to the beta. It's well worth the upgrade. You would be able to accomplish your idea much easier in 3 with a physics cloth cylinder, but with 2.6 equalsequals is right.

avatar image
3

Answer by buestad · Nov 29, 2012 at 02:45 PM

PhysX (the buildt in physics engine) is useless for creating ropes/chains using RigidBodys and ConfigurableJoints if you are attaching anything "heavy" to the end. The reason is that PhysX only has an itherative solver. You need a direct solver for this.

I've done some testing using OpenDynamcsEngine and the direct solver (use the world.step() function, not the world.quickStep() which uses the itherative solver). ODE is originally written in C/C++ but there is a port to Java called ODE4j which quickly can be compiled to a C# .dll using IKVM

My tests so far is really promising!

alt text

The attaced image shows my setup: The load of the ball is 10 000kg, and the steel rope is 47mm thick whith a densyty of 7000kg/m2 which is close to iron. The crane parts are 3 000kg for the main jib and the king(the cylinder thing) and 2 000kg for the knuckle jib. Both jibs are attached using limitless ODE hinge joints and the hydraulic cylinders which hold everyting up are limited ODE PRJoints (whiche is like a slider and a hinge put together)


capture.png (35.0 kB)
Comment
Add comment · Show 12 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Fattie · Nov 29, 2012 at 02:49 PM 0
Share

it's admirable you did work with ODE http://www.ode.org in Unity.

it's an interesting observation that the usual ropes everyone uses in PhysX (just get any of the "ropes" kits from the asset store) are not suitable for a weight on the end.

avatar image LucaH007 · Dec 08, 2015 at 06:39 PM 0
Share

@buestad How did you integrate ODE exactly? It's not working how I tried it :/ Can you help me?

avatar image buestad LucaH007 · Dec 09, 2015 at 09:31 AM 0
Share

@LucaH007 It's a wile back but I'll try to remember....

I made this at work so I have a layer on top of ODE4j so my implementation is probably a bit different than a clean ODE4j implementation. But it shoud be possible without this layer.

First you need to make a .dll of ODE4j using I$$anonymous$$V$$anonymous$$. Download the latest I$$anonymous$$V$$anonymous$$ and ODE4j. I$$anonymous$$V$$anonymous$$ expects one or more .jar-files, so if you download the source code of ODE4j I guess you will have to ANT it...

When you have your C# ode4j.dll put it inside the Assets folder together with the I$$anonymous$$V$$anonymous$$ .dlls

Then you have to start to make a bunch of C# scripts to put on different GameObjects in Unity. The diffetent C# scripts should contain the ODE objects. Start implementing World and Body. Remember that the instance of World has to be created before you can create instances of Body, so you need to implement some kind of system that makses sure that the instance of World is created first, or a callback when it is created. You don't have control over which C# script of which GameObject is started first...

By the way, when using I$$anonymous$$V$$anonymous$$ you have to set the the API compatibility level to .NET 2.0 (not subset)

avatar image LucaH007 · Dec 13, 2015 at 04:14 PM 0
Share

@buestad First of all, thanks a lot for your answer! I stuck right in the beginning at converting ODE4j to a jar and then to a dll file... I got an ode4j.dll file but I can't call it in Unity by script... (For your information: I'm beginner ;) )

But I found out that you can use the original ODE library in Unity somehow. (http://docs.unity3d.com/$$anonymous$$anual/NativePlugins.html)

Now I don't know how to go on xD

avatar image buestad · Dec 14, 2015 at 08:59 AM 0
Share

@LucaH007 if you use the original ODE written in c++ you'll have to add some information so that the C# code knows where to find the functions inside dll. I am no expert in c++, C# or dlls in general (by far), so therfore I went through I$$anonymous$$V$$anonymous$$ which generates C# spesific dlls.

I made a jar of a version of ODE4j which was on my drive. I think it is ode4j 0.12.0-j1.4, and compiled a dll with ikvm-8.1.5717.0. Then I included the dll, together with all dlls of I$$anonymous$$V$$anonymous$$ (the x86 versions) and made a simple test project in Unity 5.2.2 x86.

I will P$$anonymous$$ a zip of it to you if I can figure out how :)

avatar image LucaH007 · Dec 14, 2015 at 06:07 PM 0
Share

@buestad That would be great! Unity ropes leave me desperate :D

I think there is no way to P$$anonymous$$ via unity forum/answers so just send me the zip to this temporary email: LucaH007@cuvox.de :)

Show more comments
avatar image
2

Answer by King_Kurl · Aug 27, 2016 at 06:54 AM

Not sure if you already got what you needed but I remember some time ago I was looking for the same thing and stumbled on this script which pretty much turns a line renderer into a rope. I don't remember how well it worked but in case you want to give it a try here's the link.

http://wiki.unity3d.com/index.php?title=LineRenderer_Rope

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image andythepandy93 · Aug 27, 2016 at 10:07 AM 0
Share

This works, but unfortunately still suffers from the same issues that all ropes made using PhysX seem to suffer from: the joints can stretch too much and go unstable is you have a mass ratio of more than ~1:10 for what's on the end of the rope. Things get better dramatically when position and velocity iteration count are increased to ~50, however this leads to big performance issues. Good find though! and certainly a solution if you don't need big forces in the rope

avatar image mrvv · Jan 08, 2017 at 12:45 PM 0
Share

UPVOTE !! for most people this answer still is the best answer. they type "make rope unity" in google and arrive here because the title states "how do you make ropes?". and this script is a perfect answer for this question. this script works perfectly even with unity 5.4

avatar image idbrii · Feb 16, 2018 at 07:14 PM 0
Share

This is helpful, but was confusing to get working at first (I didn't have objects far enough apart).

Add this to get a menu item that adds an example to your scene. Then hit play, open Scene panel, and grab "start", and wiggle it!

 using UnityEditor;
 // ...
 [$$anonymous$$enuItem("Tools/Setup Rope Example")]
 static void CreateExample()
 {
     var end = new GameObject("end");
     var rb = end.AddComponent<Rigidbody>();
     rb.constraints = RigidbodyConstraints.FreezeRotationX
         | RigidbodyConstraints.FreezeRotationY
         | RigidbodyConstraints.FreezeRotationZ;
     end.transform.position = Vector3.forward * 10.0f;
 
     var start = new GameObject("start");
     rb = start.AddComponent<Rigidbody>();
     rb.constraints = RigidbodyConstraints.FreezeAll; // no movement so everything dangles off of it
     var rope = start.AddComponent<RopeScript>();
     rope.target = end.transform;
 }
avatar image
1

Answer by daneyuleb · Feb 25, 2018 at 02:16 PM

Has anyone got the c# version of this to work?
Seems broken.

I drop the script in, attach my target object, and the rope part seems to work--a segmented rope attaches between the anchor object and the target--but... the target object deforms as it moves, squeezing and stretching all over the place.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

11 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Is it possible to make a realistic rope using the interactive cloth? 0 Answers

Hinge Joints that Don't Limit? 0 Answers

reading forces applied to a rigidbody 1 Answer

Creating a rope using skinned mesh renderer 1 Answer

Distribute distances between configurable joint links 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges