Search Unity

New Rope In The Works

Discussion in 'Made With Unity' started by reveriejake, Sep 1, 2011.

  1. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    819
    Hey guys, it has been awhile and everyone is asking for ropes. I have 300+ votes for CONTINUE TO SUPPORT so I guess I have to continue ;)... Tonight I spent about 2 hours working on the next rope script and I need you to give me some input on the direction.

    I am aware that you are all looking for the ability to Climb the rope so that will be in there. I know some of you might have already found a solution to this but I would still appreciate any help in designing the perfect rope system.

    The version I have put on here is a very very limited version. The only thing it does is makes chains using the capsule collider, but I will continue to add to it as it gets tested out.

    The thing this version DOES have that is new, is the ability to lock the rope to a plane. There is a variable in the inspector for the rope called "Constraint Plane" that has 4 options ["None", "X_Y", "Y_Z", and "Z_X"]. If you are making a 2D game and the camera is facing the Z direction for example. You would select the "X_Y" plane to constrain the rope to ONLY the X and Y directions. If your camera was Facing towards the Y direction, you would want to select the "Z_X" plane option.
     

    Attached Files:

    Last edited: Apr 16, 2012
  2. web76

    web76

    Joined:
    Nov 4, 2009
    Posts:
    150
    Great, to see you back on the rope! I have some trouble with the capsule colider on V3, there are big openings in the joints, When I use the mesh render, look attachment..
    Is this different in this version?
    I am using Rope V3..

    Kind Regards
    Kjell A
     

    Attached Files:

  3. kerters

    kerters

    Joined:
    May 13, 2011
    Posts:
    164
    looking good!
     
  4. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    819
    Hey Kjell! I was about to write you an email but I figured you would see this post first ;).

    The way the old script determined the gaps in the capsule colliders is simply by making the collider heights 1.25x taller than the distance between the joints. I can either add a variable to that which allows you to set the capsule scale or I can go ahead and make it 1.5x taller. I am not sure if I would be able to add a sphere collider in between the joints but I could try that too.

    As for the Second image, Are you using Capsule colliders on that rope too? Against a mesh collider?
     
  5. web76

    web76

    Joined:
    Nov 4, 2009
    Posts:
    150
    Yes, I know it is more costly in terms of performance, but frankly I dont see any difference. The rope behaves the same if I use primitive colliders also..
    A variable would be great, or maybe I'll find it in you code also, what is odd is that the capsule collider is perfectly overlapping in the edit mode, and it doesnt stretch that much either, maybe the solution is to overlap even more, colliders hinged togeather is not colliding with each other anyway.

    The posibillity to use custom mesh colliders, with or without convex collision would also be nice, maybe use the collision that is defined in a prefab?

    PS: I tried the new rope and I noticed the scale on those chains, if 1 unit is one meter, they are huge, like 4x8 meters big..

    But then again what is one unit in unity,,

    It got unstable when I tried 200 links that was about 1 unit big.. the rope was 80 units long..

    Kjell A
     
    Last edited: Sep 1, 2011
  6. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    819
    I didnt do any scale on the demo ;) So they are 4.2 meters or so long.


    Yeah 200 links is a lot ;) and I cant do my cheat anymore as it crashes unity. So I am not sure how I will be able to deal with the unstable links. Maybe write clamp code for it... I dont know..
     
  7. web76

    web76

    Joined:
    Nov 4, 2009
    Posts:
    150
    I guess it is physx, but in your scale I can easilly run 200 links.. I think the mass on the rigidbody, suits your scale better...

    I beta tested physx for quest3d also, and the developers for that said that they used the configurable joint for rope, that was always faster than other ropes, because all joints in physx was an limited version of configurable joints.But I dont know if the same applies in unitys version,
    oh and physx also was hardware accelerated there. The same problem with unstable joints also was there, but in much less form.
    But the rope system was not as userfriendly.. I hated that quest3d did not have local axes, every transform that was not in x, y, z vector got really heavy..
     
    Last edited: Sep 1, 2011
  8. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    819
    I only tested 100 links... and it was shaky on my computer.
     
  9. web76

    web76

    Joined:
    Nov 4, 2009
    Posts:
    150
    yes it got a little shaky with me also, I forgot to mention that I made a floor underneath the rope
    The old rope (V3) handles it okay, with some tweaking.
     
  10. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    819
    Shouldn't be too much difference from V3 to this version. I have changed to Configurable Joints over Character Joints to let me have a bit more control over them.
     
  11. web76

    web76

    Joined:
    Nov 4, 2009
    Posts:
    150
    But still, would love hardware accel on the physics, at least an optional version of unity, is it so that mac users cannot get hardware acceleration from physx?
     
  12. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    Me, too! See the link in my signature. :)
     
  13. web76

    web76

    Joined:
    Nov 4, 2009
    Posts:
    150
    Hi, just want you to know that I am eagerly awaiting for whatever update you make on the rope :)

    Kjell
     
  14. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    819
    ;) Ok well I will try and get you what you want!

    I added your sphere colliders at the joints by the way.
     
  15. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    819
    Im going to post an update tonight on the rope... The new update include 2 features that you guys have requested..

    Sphere collider at the union points. (Include Sphere Colliders variable in the inspector)
    Clamping feature that hopefully limits jitter and breaking. (Clamp Type Clamp Error variables in the inspector)
     
  16. Andrew_atl

    Andrew_atl

    Joined:
    Sep 21, 2010
    Posts:
    103
  17. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    819
    Ok here is the next package..

    • Added Sphere Colliders At Unions
    • Added Line Renderer Support
    • Added "Clamping" Feature To Reduce Tearing

    Probably from here on out I am going to be putting the new packages on my site ;) but I am lazy tonight so its attached here!

    Have fun, still open to suggestions!
    Jake
     
    Last edited: Apr 16, 2012
  18. web76

    web76

    Joined:
    Nov 4, 2009
    Posts:
    150
    Great, will try it out! Is it really nessesary to have sphere colliders in the joints? Is'nt there enough to just extend the capsule colliders so the overlap each other halfway?

    When we want a prefab object, could'nt you use the prefabs collider in the rope? Is it to slow or something?

    Thanks
    Kjell A
     
  19. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    819
    Yeah I have asked about the prefab collider thing before where you build your prefab with the collider already in it. I could include that.

    As for the sphere collider at the joint thing, I know what your saying but I think having the capsule colliders extended will still give you the problem where it separates the rope at the joints. I might give more control over how long the capsule colliders are but if they are too long then it doesnt look good colliding.

    You are trying to do something interesting with your chain Kjell ;). You have many issues that bring out the worse in rope physics using PhysX like a really long chain that is physically picked up by a claw and drug across a surface which is pretty complex physics!

    I was recently looking into making my own physics for the rope but that would require quite a bit of work I think.

    Jake
     
  20. web76

    web76

    Joined:
    Nov 4, 2009
    Posts:
    150
    Got an error when I try you sample file..

    Assets/RopePack/Rope.cs(71,17): error CS0246: The type or namespace name `BezierPath' could not be found. Are you missing a using directive or an assembly reference?
     
  21. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    819
    Oops... Yeah I was trying to impliment the Bezier curve into it so you can kinda draw out the shape of your rope and the rope will be built along that curve.

    It is okay to Comment out or erase line 71:
     

    Attached Files:

  22. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    819
    17 people downloaded that package and your the first one to point out the issue ;)... If you guys download the rope and there is something wrong PLEASE let me know!

    PS: The rope does throw a lot of warnings because its still sort of in ALPHA mode so dont worry much about those and sorry if it clutters up your console!

    Jake
     
  23. web76

    web76

    Joined:
    Nov 4, 2009
    Posts:
    150
    Oh, bezier curve would be awsome!!
    I think the reason I was the first one to try it out, is that most of us have some of your other packages up and running, and it takes some work to implement the new one, but still I could assist you much more in testing if you want to hear me complain and nag :)

    It worked great now..

    The prefab with custom collider would work great with chains and alike, but maybe not for the rope, but would love some custom collider control there also..

    I see what you mean with the sphere collider thing, and I guess it depends a little of how much you bend the rope, and of course wich resolution you have in the rope, if the rope is kinda stiff it still looks good if the elements it quite small... and colliders that are jointed toghether dosn'nt collide with eachother right? But I guess you have tested this more than me..

    I get the feeling that there is not many that tries to use ropes and physics, the hard stupid way that I do,I think it is a easier way of programming also, but I would really hate to switch the cranes and other stuff to move or rotate rigidbodys, when I now use target at the joint and get to see the heavy swinging of the cranetip, and I can see how heavy I lift, just watching the crane parts struggle, it is valuable feedback when training..

    Kjell A
     
    Last edited: Sep 21, 2011
  24. web76

    web76

    Joined:
    Nov 4, 2009
    Posts:
    150
    Any progress now Jake?

    Kjell A
     
  25. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    819
    None yet sorry. I am in the process of getting a half dozen new iPhone apps out so my time has been stretched thin! Might get more time to work on this in a few days though.

    Jake
     
  26. web76

    web76

    Joined:
    Nov 4, 2009
    Posts:
    150
    I guess you got to earn money somewhere also :)
     
  27. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    819
    Lol yeah unfortunately rent is high and food is expensive :(.
     
  28. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Hiya, your latest package unzips to a bunch of gibberish folders on my mac, any chance of a new package? curious about ropes at the moment!
     
  29. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    819
    Hey yeah I have found someone who has the files so I will be fixing the script late this weekend. Hope to have a new working version by Monday morning PST!

    Jake
     
  30. web76

    web76

    Joined:
    Nov 4, 2009
    Posts:
    150
    Something new, or the same package?
     
  31. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    819
    Hopefully something new ;)
     
  32. web76

    web76

    Joined:
    Nov 4, 2009
    Posts:
    150
    I guess you didnt say wich monday , Jake :)... But still here, showing my support..
     
  33. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    819
    Yeah I uploaded the scripts to my website last night but I didnt get the new updates in these versions yet. I have a crazy schedule leading up to Christmas at my work so things are not going as I planned and I have some programming work that still needs to be taken care of before I can REALLY spend time on the scripts.

    The versions on my website are Version 2.0 which has the raise/lower rope systems in it as well as Version 4 which I fixed the "Bezier Curve" error everyone was getting. Check those downloads out on REVERIEINTERACTIVE.COM


    Sorry about all of this guys!
     
  34. web76

    web76

    Joined:
    Nov 4, 2009
    Posts:
    150
    Of course you dont have to say youre sorry! You are doing a great job, that I am not capable of doing myself!
    But I really hope you find the time flickering with the script again, I can dig in and really test it now if you want ! Many projects with winching ropes ahead!
     
  35. immFX

    immFX

    Joined:
    Mar 20, 2010
    Posts:
    110
    Jake, the latest version is pretty good!
    I think it's better than the old one in terms of collision and in elasticity of rope.

    One thing I'd recommend in your script is, when BuildRope() is called, to automatically generate as many joints as needed depending on the distance of Point A and Point B. This way, you don't have for example to manually raise the Link Scale value in order to have a "correct" chain (i.e. chain links not separated from each other). It's an easy change but I'm not sure if you find it a good idea.

    All things said, it's unfortunate that the rope still goes crazy when stretched too much...

    Keep up the good job.
     
  36. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    819
    @immFX

    Hey thanks for sharing your ideas. The reason I didn't do it the way you were speaking of is because I wanted it to be flexible when it came to adding your own joint meshes for chains. When you do that the scale has to be constant which turns out to be a hassle for the artist or even the person setting up the scene who has to adjust it. I was trying to figure out a way to set the scale depending on the mesh's bounding box, but I have ran into issues doing it that way.

    I will eventually have to use the method you are talking about though once I implement the bezier curves.

    Keep the suggestions coming!
    Jake
     
  37. web76

    web76

    Joined:
    Nov 4, 2009
    Posts:
    150
    Cant you just set a variable for the wanted length between each joint? Then we can just measure our custom mesh and You are still able to generate as many joints as needed between point a b
     
  38. web76

    web76

    Joined:
    Nov 4, 2009
    Posts:
    150
    The best rope would have been one that has many joints around where it collides with other mesh and fewer on the parts that are between..
    You get resolution where needed..and maybe a more stable rope.
    Another idea is to use far less joints for the physics Of the rope and interpolate with many more joints for the visual update..
     
  39. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    819
    @web76

    I could add a variable that does what your saying but I didn't think there was much wrong with what was already there honestly. The only reason I would want to change the current setup is to make it easier for beginners to be able to take my script and set it up as fast as possible.

    As for using far less joints per section, there is nothing stopping artists from making a mesh that has 3 or 4 links in it and using that as the joint prefab which would give you more links per joint.

    I never had the intention of writing a script that everyone seems to need and at the beginning this script was just a math exercise for me. Unfortunately for me it has grown into something much larger which has tested my ability to provide something useful. I have always tried to keep the script as simple as possible to use and that has been and always will be my primary goal. Lately I have been asked to add features that are either beyond my scope of understanding or impossible to do due to limitations imposed by PhysX. I am trying to work through these issues and find work around to some of the limitations from PhysX. As for fixing my scope of understanding, I would not mind seeing more people in the community adding there features to the script and posting it to the forum. We could all learn from others experiences!

    If you know how to program or know anyone who does then you are welcome to alter the code as you see fit. And if you are able to advance the script further or add better features, by all means post, it to this forum!

    Jake
     
  40. PolyMad

    PolyMad

    Joined:
    Mar 19, 2009
    Posts:
    2,350
    This is SO cool.
    Ropes should be an extension present in ANY engine by default.
     
  41. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    819
    PS: Kjell, I should probably be getting with you anyway to figure out what you think the best way to go about this is. I don't remember if you said you didn't have Skype or not but if you do please give me that information and I will catch up with you later on. I don't use MSN much anymore so I really don't get a chance to catch you on there.

    Jake
     
  42. web76

    web76

    Joined:
    Nov 4, 2009
    Posts:
    150
    All your rope versions has been userfriendly enough, I cannot help you with the programing, but might be able to help you with the logic, and Of course it might be biased to my idea of what is needed!
    For my part I am really on need Of the hoist and lower system, and how we can do that the best way.
    I think we are almost there with the rope, with the current limitations Of physx..
     
  43. immFX

    immFX

    Joined:
    Mar 20, 2010
    Posts:
    110
    Jake, is there a way to know when the rope is tightened enough when pulling it with the PullRope() function?
    Right now, pulling works, but the rope goes crazy when PointA and PointB are restrained and the rope tightens up.

    For example, I found out that, for specific number of joints, playing with the collectionRadius can achieve a limit to pulling if you have a condition like:

    Code (csharp):
    1. float distanceAB = Vector3.Distance(PointA.transform.position,PointB.transform.position);
    2. if ((joints.Count-movingLink)*collectionRadius < distanceAB)
    3. ....
    4.  
    Any better ideas?
     
    Last edited: Jan 5, 2012
  44. db3dfx

    db3dfx

    Joined:
    Feb 19, 2012
    Posts:
    1
    Hey there, love your script, I am in the process of creating a demo for a client, a simple 3d fishing game. I am yet to find/write a rope script which will allow me control over the length/stretch, do you think its possible to integrate it into your script?

    I need the ability to set the length and Divisions of the fishing line on creation and then modify it during runtime. And also set a maximum length so the fishing line would only stretch to that limit and tighten. any ideas? thanks

    Dan
    DB3DFX
     
  45. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    819
    Sorry guys, I really don't have any ideas on the stretching. If anyone on the forum does please let me know!

    Jake
     
  46. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    The stretching is a limitation of PhysX joints. If you google you'll find that any engine that uses PhysX has this same problem. There are work arounds, but they slow down the playback so much that it's only useable with very short ropes. The other option would be to write your own rope physics (which some, including myself have tried) but so far that also is only useable with short lengths of rope. Perhaps if we had multi-core / multi-thread support for the physics engine we might be able to do more, but for now it's just not feasible.
     
  47. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    819
    Thanks for the explanation! I remember you saying something about that before but its been a long time sense I've worked with the scripts I had forgotten why I was struggling with it.