Announcement

Collapse
No announcement yet.

Attach spline-points to moving objects

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Attach spline-points to moving objects

    Hi,
    I created a simple cable blueprint.
    Click image for larger version

Name:	cable_bp.jpg
Views:	3972
Size:	156.6 KB
ID:	1487397
    All works fine, but I want to attach the start and end point of the spline to dynamic meshes so that the cable stretches between them.
    I looked at a lot of tutorials and spent hours of googling but somehow and can't figure it out.
    If someone could point me in the right direction I would really appreciate it.
    Thank you in advance.
    Mirko

    #2
    You need to update the spline mesh components as you update the spline points, too. Essentially what you're doing up there but without adding the components.

    Comment


      #3
      It took me quite a while to figuer out how to reference my target objects. I think i am on the right track, but somehow I can't get it to work.
      Here is what I did so far:
      Click image for larger version

Name:	cable_eventgraph_1.jpg
Views:	2380
Size:	209.4 KB
ID:	1490013
      To get startet I concentrate only at the start and end-point of the spline. Figure the rest out later...
      Click image for larger version

Name:	cable_eventgraph_2.jpg
Views:	2467
Size:	176.1 KB
ID:	1490014
      Just guessing that world position is the right way to go. But no matter what coordination-space I use I can't get it to work properly.
      Here is the Result:
      Click image for larger version

Name:	cable_result.jpg
Views:	2282
Size:	74.4 KB
ID:	1490015
      Any advice would be highly appreciated.

      Comment


        #4
        For starters, your Start and End object are being set to null...

        Did you forget to connect the wire from the loop?

        Comment


          #5
          Well... that's kind of embarrassing.
          I literally spent over 5 hours today, trying to figure this out, and started over a couple of times. So yes... that's exactly what I forgot.
          I had to change the GetWorldLocation to GetActorLocation. After that it worked like a breeze.
          Anyway, thank you for pointing this stupid mistake. I keep you updated...

          Comment


            #6
            Not sure what you're trying to achieve but there is a cable component in the engine already (a plugin that's enabled by default). It simulates physics and its ends can be attached.
            It's somewhat simple and looks like this:

            https://i.gyazo.com/1fa19d389805dc6b...61da803581.mp4

            Perhaps it's enough for what you need.

            Comment


              #7
              Didn't know about the cable component. I just wan't a calbe with connectors on each end. So it is very close. But I probably need more controll at the beginning and end of the cable.
              I will experiment with this component some more and post the result..

              Comment


                #8
                Hi,
                it is as I thought. The Start and Endpoint just ignor the rotation of the start and end connector.
                I need it to interpolate at the ends so that it curves accordingly. Right now it looks like it is not really
                connected:
                Click image for larger version

Name:	Cable_Component_Test.jpg
Views:	2286
Size:	49.1 KB
ID:	1492869
                Any ideas??

                Comment


                  #9
                  If you need a wire that will coil realistically and support custom tangents at specific points, the cable component will not cut it. I believe it was designed as a cheap, real-time physics based, free-hanging rope/chain.

                  However, you should be able to achieve an interesting (but simplified) effect by dynamically adjusting the length of the cable based on the distance between the attachment points and (optionally) enabling stiffness. This should take care of
                  I want to attach the start and end point of the spline to dynamic meshes so that the cable stretches between them
                  Trial and error might be required to get the look you're after:

                  https://i.gyazo.com/9057d28d3e0ba2e7...eb5acf9a34.mp4
                  • you can disable Gravity, this will keep the cable straight
                  • or lower the gravity and increase the Cable Force (Z)
                  • make the length a bit shorter/longer than the distance between the attachment points
                  Here's one with inverted force, low gravity scale and length set to 120% of the distance between attachment points:

                  https://i.gyazo.com/6c3998c5ae78c1f0...1b20800876.mp4

                  Using splines for this will give you access to each point's arrive and leave tangents, enabling greater control over the stiffness of the whole thing. But you will need to write the algorithm yourself.

                  [edit]: you might be able to use a curve editor to paint the curve and then apply it to the length of a spline and calculate positions of the spline mesh component. Untested but could work.

                  A common sight that's rather difficult to simulate:

                  Click image for larger version  Name:	Tangled-headphone-cord.JPG Views:	1 Size:	18.6 KB ID:	1493261
                  Last edited by Everynone; 06-24-2018, 05:42 PM.

                  Comment


                    #10
                    Is it possible to import animated Splines, and just use UE to put the Splinemesh on?.
                    I don't need Realtime simulation just a fixed keyframed animation.
                    Maybe I could use a long bone-chain as an alternative and import it as skeletal-mesh. Might be a lot of work to animate thou.

                    Comment


                      #11
                      Have a look at this, it was quickly put together. With some tinkering, you might get what you need:

                      https://drive.google.com/file/d/1QhX...V7H0pClAc/view

                      The only things that are animated here are the white anchor locations and their rotations. Is this roughly what you're after?

                      Comment


                        #12
                        Yes, that is exaclty what I looking for. Do you have any links to tutorials or something?

                        Comment


                          #13
                          I've got no tutorial but here's how it's done. Do note that this is rather crude and can be vastly improved.

                          The entire thing is self-contained, controlled by a single actor:

                          Click image for larger version  Name:	CG_Actor.png Views:	1 Size:	64.7 KB ID:	1495832

                          It is using only 2 Spline Mesh Components and a Spline with 3 points; it can be extended/made more dynamic should you desire more fidelity, of course. The anchors dictate start/end positions of the spline points 0 and 2, and their rotation. (anchors' forward vectors are used and tangents)

                          You will need to call the above functions whenever the spline needs an update. The animation I attached was using a timeline and called them every frame.

                          Click image for larger version  Name:	Upd.PNG Views:	1 Size:	425.1 KB ID:	1495833

                          The above places spline points 0 & 2 at the anchors and the midpoint between them with some fake gravity - the more further apart 0 & 2 are, the lower the midpoint goes. You could clamp this value by linetracing towards the floor (and dynamically adjusting midpoint tension) so the mesh never clips it and sits pretty on top. It will never resemble actual simulation, though.

                          Click image for larger version  Name:	bend.PNG Views:	1 Size:	232.4 KB ID:	1495834

                          We have 3 points but only 2 SMCs hence the Branch.

                          Hope it helps.
                          Last edited by Everynone; 06-30-2018, 10:48 AM.

                          Comment

                          Working...
                          X