Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Rope Script V2 now availiable - 8/08/10

Discussion in 'Made With Unity' started by reveriejake, Nov 19, 2009.

?

Should I continue to support this script

  1. Yes I need this script and appreciate your support!

    94.4%
  2. I think its fine how it is!

    3.2%
  3. I know enough about programming to fix it myself!

    2.5%
  1. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    819
    Last edited: Jan 2, 2013
    Hasan8 likes this.
  2. Discord

    Discord

    Joined:
    Mar 19, 2009
    Posts:
    1,008
    Very cool, thanks for sharing! I will definitely have to give this a try later.
     
  3. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    819
    Here is what I think is a neat looking screenshot I made using the rope script... (not the best looking Normal Map on the floor for sure)

    If you dont mind, I ask whoever is using the rope script to show there rope in action here!

    Jake
     
  4. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    819
    I have fixed the error and included a couple new updates which include support for mesh collision on the rope and bump map support.

    I still need to fix a few more things but I dont want to have to continue spending time if there is no intrest so post a response on the poll above.

    Thanks!
     
  5. Thomas-Pasieka

    Thomas-Pasieka

    Joined:
    Sep 19, 2005
    Posts:
    2,174
    I wants it! Give it to ussss! ;)

    Thomas
     
  6. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    819
    Fixed error where the first joint is static. Now all joints rotate properly!

    Just a note:
    The 3D rope is VERY render intensive! I am working on a LOD system for it, but there are no guarantees on whether it will work ;) so Here you go again and I hope I am helping and not being annoying with this ;)
     
  7. Deleted User

    Deleted User

    Guest

    oo thanks. One question tho.. Can it be done so only 1 side of it is attached and other one is loose?
    Say, for example I want to make it so char could grab rope and swing over, to do this I need to have one side of rope attached to rope holder and other one must not be attached to anything, it has to be loose.

    Is it possible with this script?


    thanks
     
  8. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    819
    yeah there are 2 variables called "startRestrained" (Green Gizmo) and "endRestrained" (Red Gizmo)...

    If you make sure that "endRestrained" is unchecked and and the other is checked, then you should be good to go!
     
  9. Deleted User

    Deleted User

    Guest

    Woah thanks a lot! *leeches the code and runs off to check if it works*

    This will be perfect for Swinging over trap on my Agility skill course I'm making for our Runescape project at the moment :)

    EDIT:
    I'll upload a nice high res rope texture with normal map for you people in a minute, if I can find it :)

    EDIT2
    Found it! Enjoy ;)
     

    Attached Files:

  10. Deleted User

    Deleted User

    Guest

    Hmm.. I attached the rope script to empty game object, checked "Start restrained", unchecked "End restrained" and try to run it but it keeps giving me error that I need to attach gameobject to Target.. What do I need to assign as target if I want the end of rope to be loose? :eek:
     
  11. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    819
    I should have labeled that differently but assign the second end of your rope to "target"

    so put in a second empty game object and assign it to target. At that point you should see the gizmos in the editor that will represent your rope.

    Let me know if you need anything else!
     
  12. Deleted User

    Deleted User

    Guest

    ok it worked, thanks :p
    Now to think how to add some rope effect to it so it would be "rope-ish" when collides with gameobject that is heavier. Now my char just bangs into it as if it was a wall or something :D
     
  13. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    819
    here is a video of a box bumping into the rope..
     

    Attached Files:

  14. Deleted User

    Deleted User

    Guest

    oh thats nice, would you mind making a small scene with the box bumping into the rope, making a unity package out of that scene and uploading here? That would be just brill! :eek:
    Or is it already done and there's just something wrong with my character's weight?
     
  15. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    819
    I am assuming your character is using a rigidbody. What type of collider do you have on the rope?
     
  16. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    819
    Ok so I copy and pasted my code from this forum and noticed I forgot to update the TubeRenderer script in my last update, so I went ahead and did that which should fix any errors that popped up when you first used it.

    And here is a demo project for you so you can see how to make it run into the rope and make it move, you can mess with the ropes mass and the players mass to get what you want. I think your just not getting enough Umph behind your plow ;) so you might wanna move a little faster to hit it harder or increase your mass. Just need to play around with settings to get your desired effect.
     
    Last edited: Jan 2, 2013
  17. Arsonide

    Arsonide

    Joined:
    Nov 16, 2009
    Posts:
    43
    You said that the rope is very render intensive. How render intensive, exactly? Our game utilizes a lot of wires placed by the player going around the level. Right now we are using Linerenderers for those, and that looks OK for wires...but our game also calls us to lay some pipes around the level, and I think linerenderers aren't good for that job. Tuberenderers might even look better for the wires, depending on performance.

    The way our game works though, the player will lay one segment of the tube at a time by clicking on the walls...and those segments will be constrained to the walls unless something happens and breaks that constraint/breaks the pipe, in which case (hopefully), using your script will cause them to flail about.

    So my questions I guess are of performance and constraint - can you constrain each segment of pipe using this script?
     
  18. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    819
    Render Intensive = 800FPS down to around 190FPS
    EDIT: I just tried with 4 sides and around 12 joints and it was rendering with close to 300FPS in a scene like you see in the image below
    But that also depends on the detail you put into it. Segment numbers, joint detail, bump maps, blah blah...

    HA! You know what, I just this second made a scene with the tube flopping around wildly! Thats so weird. SO yes it can constrain the pipe, Secondly, I am working on the LOD system, it looks OK right now but not amazing as the LineRenderer isnt as bright as the tube renderer ;). Anyway here is a pic of the tube flailing around for your amusement!
     

    Attached Files:

  19. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    819
    Just out of curiosity, is that line renderer thing your talking about custom or the one I made from the Wiki?
     
  20. Arsonide

    Arsonide

    Joined:
    Nov 16, 2009
    Posts:
    43
    It is custom, we have set up a custom Wire object that conducts power between things, and you can click around the walls of the ship to add vertexes to it, which are then added to a LineRenderer component.
     
  21. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    819
    Ah cool!

    My first attempt at making rope involved the same idea your talking about. You had to drag a loose wire over to a pad to make the light bulb turn on.

    Unfortunately for me that was pre-rope script and I made everything within Maya, including joints and binding! Its cool to hear your kinda doing something similar and I would be interested to see what you do with my script if you do end up using it :).

    You can request custom stuff if youd like and I will include it!

    I attached progress on the LOD system.. Keep in mind, this is my slower G5 im using at the moment sense my friend is playing the sims on my Macbook pro ;) lol
     

    Attached Files:

  22. Aram-Azhari

    Aram-Azhari

    Joined:
    Nov 18, 2009
    Posts:
    142
    wow!
    It looks even better than before!

    I like the bump mapped ones! I can think of a big worm that is going through tunnel just like "The Void" , except with nice bump mapping.

    Can it also support parallax mapping ?

    Cheers,
     
  23. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    819
    Hey! Yeah it supports it but as mentioned before, there is still a UV mapping issue on one of the sides, so it may look funky depending on what your doing with it.

    I am also looking for an answer on how to BIND skin to a procedurally generated set of bones, so anyone with an answer to that will be praised by me forever ;). I think bound joints instead of constantly rebuilding the mesh would be WAY WAY faster ;).
     
  24. Jolon

    Jolon

    Joined:
    Jan 22, 2009
    Posts:
    31
    This is totally great.0

    Could you could put this up on the wiki? I stumbled upon this, and it's very useful.
     
  25. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    819
    Ok I have posted it on the Wiki. I also have a link to download the scripts in a .zip file from my website!

    Thats also where I will be posting packages and more stuff soon!

    www.reverieinteractive.com
     
  26. groovedude

    groovedude

    Joined:
    May 28, 2009
    Posts:
    48
    This is really wonderful! I was just thinking about making a rope and having a character swing from one rope to another.

    However, how would you go about having a character "grab" this rope?

    I looked at the character joint doc and I didn't see a way to access a joint so that you could parent an object to it.

    For instance with colliders you can get hit info and parent an object to another. But I don't think the same would work with this scripted rope. If I understand this script you are using a target at the end of the rope so maybe there might be some way to have a character grab the end of the rope...but I can't think of a way that a character could be attached to wherever it hit.
     
  27. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    819
    Yeah there are character joints in it, but it also has collision spheres at each joint location. I made a character stick to the rope just by saying on collision, attach a fixed joint to the object we collided with. That worked well.

    Send me a PM if you need some better help with this but the collision spheres are in there :)
     
  28. groovedude

    groovedude

    Joined:
    May 28, 2009
    Posts:
    48
    Sorry, I was too busy admiring this and overlooked the sphere colliders. I think I understand what you're getting at, I'll give it a go. This is very impressive.

    Thank you for being so responsive!
     
  29. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    819
    Hey no problem, I try to be as helpful as possible!
     
  30. minevr

    minevr

    Joined:
    Mar 4, 2008
    Posts:
    1,018
    This is so cool,thank,

    Make Little big planet
     
  31. web76

    web76

    Joined:
    Nov 4, 2009
    Posts:
    149
    Hi, thanks for an amazing script, good work!

    But.. :D ..I am having a hard time with the collision on the rope, as you can see in my piscture I really need an god response on the collision, now the the handling of the rope with the crane feels "soft" and it often just slides right through the crane! is it possible to make good colision between the joints?

    The chain you see in the picture are having hinge joint, box collision and rigid bodies every link.. and that works fine!

    Btw the crane is completly physics driven...also the grip part when handling objects..
    Thanks anyway!!

    Regards
    Web
     

    Attached Files:

  32. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    819
    I am not sure I understand what you mean by soft and I think I understand what you mean by the rope sometimes just goes right through the crane!

    The rope uses Collision Spheres and depending on what your resolution is and what type of load you have on the rope, the collision spheres could be close together or further apart (hence why it would just go right through something). Did you try using the MeshCollision checkbox on the script? Or is your crane already using a mesh collider..
     
  33. web76

    web76

    Joined:
    Nov 4, 2009
    Posts:
    149
    Thanks for replying!
    Yes the crane uses mesh collision on some parts, I also tried with box colliders and it behaved quite similar!
    With "soft" I meant that the rope slips thorough my crane as it was made of butter or something!
    I didnt Get any good results when I checked mesh collision on the rope, the rope got very unstable.... Maybe because it collided with the end and start object box collision?
     
  34. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    I also don't entirely understand your question, is the issue stretching in the chain joints? How are you grabbing the chain with the crane? A bit more info would help.
     
  35. web76

    web76

    Joined:
    Nov 4, 2009
    Posts:
    149
    No the streching issue of the joint is not the problem I was refering to here (though that is also a problem for me).

    I am grabbing the chain only with the use of the colliders (no other trigger logic) on the crane (it has mesh coliders and box colliders).

    The mesh checkbox gets the rope to act funny, it just "lives" and doesnt collide on the deck or anything?
    the rope width is only 0.05 units maybe it cannoth be that small? I am certain that my problem is physx spesific, but I hope you guys can help me....

    I know you are also using sphere collider in the rope, but could'nt you use a capsule colider that the lenght of the capsule is adjusted acording to the ropes resolution to get a more closed collision?
     

    Attached Files:

  36. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    819
    ok yeah I see what your talking about. I could use capsule colliders for the collision but when I wrote the script I was feeling lazy and just threw in the spheres so I didnt have to do the extra math involved ;). I might take another look at the rope today and see what I can do.
     
  37. web76

    web76

    Joined:
    Nov 4, 2009
    Posts:
    149
    Hey thanks, you have already done a lot!!
    You are also close to getting this quite perfekt! Now it is my hope that Unity also updates the physx engine so we could get some hardware acceleration also :)!

    So do you also have an idea how I could spawn chain links instead of the rope? I probably sould use configurable joints instead of character joint!

    Kind regards
    Web
     
  38. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    I've found that the physics system's accuracy is very much -frame rate- dependent. For something as complex as you're doing here if the frame rate drops below 50 or 60 fps you may see objects passing -through- each other (it apparently happens between frames).
     
  39. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    819
    Yeah actually you could probably use my script to spawn a chain. Instead of using the tube renderer or the line renderer to make the art you would just instantiate a prefab link at each joint iteration. You should make sure that your transform node is set to where you want the links to hinge at and with every iteration you rotate the link 90 degrees.

    Thats just how I would start going about doing it.
    And I think Character joints are just fine for use with ropes or chains.
     
  40. Phusck

    Phusck

    Joined:
    Dec 29, 2009
    Posts:
    2
    Thanks for doing all that work, the script seems very nice, i will start fiddling with it now and come back and post how it works out, I am hoping to make a grappling hook with working physics for a gadget type FPS
     
  41. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    819
    Ive done that myself and it seems to work pretty well. However, when I did it, I had to just shoot a line renderer from point A to point B, then on collision build the rope.
     
  42. X-Developer

    X-Developer

    Joined:
    Oct 31, 2009
    Posts:
    162
    This is when Cloth Physics come in handy. Good Job though!!!
     
  43. supafraud

    supafraud

    Joined:
    Jan 4, 2010
    Posts:
    2
    Noob question! How do I assign the target? I added this script to one object, and I'm not sure how to assign the target to my other object....
     
  44. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    819
    Noob questions are welcome! If there weren't any Noobs today, then there wouldnt be any great game makers tomorrow ;).

    You can do it a couple of ways. First, in the inspector under my script component you will see target and a drop down next to it from which a list will drop down so you can select the other object. (If you dont see any variables than you might have to click the arrow to the left of the script title in your object) Another way is to drag and drop the item from the Hierarchy into the target area of my script.

    Hopefully that helps!
     
  45. Cosmas

    Cosmas

    Joined:
    Jan 9, 2010
    Posts:
    133
    jj55ee,

    Can you give me a hint to the logic if I want to set the tether target to an object I want to instantiate?
     
  46. slgooding

    slgooding

    Joined:
    Jan 12, 2009
    Posts:
    112
    I need to have my "tube" set in a specific shape (actually shaped like a "J"). Is there any way to set the initial rope shape? Can I maybe attach something at points on the rope that would allow me to move certain parts of it?

    Thanks!
     
  47. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    819
    Sorry but no there is no way to set the initial shave of the tube. You could probably use the TubeRenderer itself to set the positions and create a tube because the TubeRenderer has a method that allows that, but it wont have the physics enabled on it as its just graphical.

    Sorry,
    Jake
     
  48. Luckymouse

    Luckymouse

    Joined:
    Jan 31, 2010
    Posts:
    484
    Amazing script! Thanks for sharing. It is just so fun to play it in the Editor with some collisions. I'm thinking we may make something like ponytail and attach it to character head..hehe. Just an idea what we can do about it :D

    Great Jobs!
     
  49. General Jackson

    General Jackson

    Joined:
    Oct 31, 2009
    Posts:
    73
    I have a question do I need to assign bones in a modeling program where I want the rope to bend?
     
  50. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    819
    Since the rope is generated from script you cannot pre-model the rope. If you are interested in modeling your own rope then you will have to add your bones to the model, bind the mesh to the joints in the modeling program, and then in Unity, assign each joint in the model with a character joint and connect them in order like a chain.

    Its time consuming and probably would be easier to get a programmer to make you a script that will detect your bones and just add the character joints via script.