Announcement

Collapse
No announcement yet.

Attach and actor to an actor using a 'rope' or similar.

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

    Attach and actor to an actor using a 'rope' or similar.

    Greetings!

    Once again, just seeking some input on where to start with an idea I want to put in to motion.

    Essentially I have two vehicle assets at this stage. One is a Helicopter, the other is a Tracked Tank-like vehicle. What I want is to be able to 'pick up' the Tank vehicle while controlling the Helicopter, and have it dangle from below the Helicopter like it's attached by a rope.

    The two pictures below are taken from a game called Hostile Waters. This is essentially a similar solution to what I have in mind.

    Click image for larger version

Name:	HostileWaters 2015-10-10 23-01-05-351.png
Views:	1
Size:	518.4 KB
ID:	1169802
    Click image for larger version

Name:	HostileWaters 2015-10-10 23-01-03-918.png
Views:	1
Size:	708.8 KB
ID:	1169803

    I've tried making a 'rope' model with bones and physics, and attaching one end to the Helicopter and one end to the Tank using AttachToActor/AttachToComponent, but I'm not sure if that's a solid way of doing things and I'm having a lot of difficulty with the attachment of the actors.

    Would anyone be able to provide some insight?

    Best regards.

    #2
    I think you can try constraint actor to attach rope to helicopter and second actor to attach rope to vehicle. Be aware that this kind of setup is difficult for solver to handle. More rigorous solution is how it's probably done in Arma series. Just use a single constraint actor and set it up as ball connector. Constraint actor will try to maintain distance between objects which was there when you've added it.
    "Rope" can be added on top as a cable component just for visuals.
    Youtube Channel

    Comment


      #3
      Ohh and location of constraint actor when constraint is enabled defines the root point around which ball connector will swing.
      Youtube Channel

      Comment


        #4
        Originally posted by BoredEngineer View Post
        I think you can try constraint actor to attach rope to helicopter and second actor to attach rope to vehicle. Be aware that this kind of setup is difficult for solver to handle. More rigorous solution is how it's probably done in Arma series. Just use a single constraint actor and set it up as ball connector. Constraint actor will try to maintain distance between objects which was there when you've added it.
        "Rope" can be added on top as a cable component just for visuals.
        Thanks for the help! I watched a couple videos explaining how physics constraints work and it seems pretty straightforward when doing simple things. Would I add a physics constraint to my Helicopter Blueprint, then reference it and set it's constraint targets, or would I make a new blueprint with just the physics constraint, spawn it and then set it's constraints? Or should I do it a different way?

        Comment


          #5
          You can add constraint component to any of them or you can spawn constraint actor only when it's needed. In both cases you need to provide references to specific components of both actor, for this you can make a simple interface or a function to return you a reference to component of each actor (helicopter and tank) and then provide them as input to constraint actor or constraint component.
          Youtube Channel

          Comment


            #6
            Thanks again, I think I'm getting there! I've managed to get the physics constraint working where I can pick up the tank with the helicopter. The only problem I'm encountering at the moment really is when I come to a stop with the helicopter the tank flies around like a pendulum (which I guess is sorta realistic), but I'd like it to just return to it's original state (directly below the helicopter) without the excess swinging. Another problem is that the constraint will lock it's length in at the original distance between the tank and helicopter when I first 'connect' them, so if I try to move the helicopter further to the ground (and put some 'slack' on the 'rope' so to speak) it'll just try to force the tank through the ground.

            I'm going to play with the settings and do what research I can, but do you know if there's a proper way to rectify these issues?

            Comment


              #7
              For vertical movement you need to unlock limit in Z axis (assuming that constraint Z is Up vector). For removing pendulum effect you could dynamically change limits of constraint - slowly limiting ball constraint to swing in smaller and smaller radius, or you should be dropping helicopter speed in advance before stopping completely.
              But if this is for RTS, do you really want to have physics for such features?
              Youtube Channel

              Comment


                #8
                Actually I meant to limit movement in z axis, by setting some lenght (maximum cable lenght) which it will be allow d to move. Because if you just set is as free it will fall down completely.
                Youtube Channel

                Comment


                  #9
                  Originally posted by BoredEngineer View Post
                  For vertical movement you need to unlock limit in Z axis (assuming that constraint Z is Up vector). For removing pendulum effect you could dynamically change limits of constraint - slowly limiting ball constraint to swing in smaller and smaller radius, or you should be dropping helicopter speed in advance before stopping completely.
                  But if this is for RTS, do you really want to have physics for such features?
                  Originally posted by BoredEngineer View Post
                  Actually I meant to limit movement in z axis, by setting some lenght (maximum cable lenght) which it will be allow d to move. Because if you just set is as free it will fall down completely.
                  It's a shame that there isn't an option to limit to only one direction of the Z axis (say the UP vector of the Z axis). I played with changing it from unlocked to limited and setting a value for the limit, and that does give me a result I'm looking for when I drop the helicopter closer to the ground, but when I lift off the lifting effect isn't immediate due to that limited value. I hope you understand what I mean. Maybe it should be something I could suggest to add to a future release?

                  Comment


                    #10
                    Not exactly sure what you mean. As long as constraint root is somewhere on helicopters bottom and both vehicles have collision the other Z direction shouldn't matter as tank won't be able to move in that direction as its blocked by helicopter. Or you mean something else?
                    Youtube Channel

                    Comment


                      #11
                      After lots of tweaking I have it to a point where I'm happy with the functionality, but I am having issues with a crash. I'm hoping someone can help me with this crash. For reference I'm using 4.11.0 (Preview 2)

                      The crash can be duplicated easily, the process follows:

                      1: Select a vehicle to be picked up
                      2: Pick up the vehicle, then drop it off anywhere.
                      3: Pick up the vehicle again
                      4: Try to drop off the vehicle again - THIS CAUSES THE CRASH.

                      I have uploaded a video to YouTube showing a screen capture of the crash in action:
                      https://youtu.be/CbfnTrmxtOs

                      It happens every time, and I have no clue what could be causing it.

                      Comment


                        #12
                        I managed to get it all sorted out! I've uploaded a video to my YouTube channel to show my progress: https://www.youtube.com/watch?v=TK8VsmTvTZU

                        Comment


                          #13
                          Originally posted by Inject4 View Post
                          I managed to get it all sorted out! I've uploaded a video to my YouTube channel to show my progress: https://www.youtube.com/watch?v=TK8VsmTvTZU
                          Awesome! Looks really nice. I see that vehicle starts to jitter if "cable" is too short as helicopter technically starts to push it underground. In this case you could automatically destroy constraint or dynamically edit linear limit. For example if distance between heli and vehicle is 20 meters then constraint limit is 2 meters, so "lift off" will start at 22 meters. If distance between them get's shorter, like 18 meters you could adjust limit to be 18 meters too, so heli could technically just "land" on top of vehicle with rope attached. As heli start to lift off, distance between them becomes more than 20 meters, you immediately switch limit to 2 meters and at 22 vehicle will be pulled into the air.

                          Did you found what was the reason for crash?
                          Last edited by BoredEngineer; 01-22-2016, 10:35 AM.
                          Youtube Channel

                          Comment


                            #14
                            Originally posted by BoredEngineer View Post
                            Awesome! Looks really nice. I see that vehicle starts to jitter if "cable" is too short as helicopter technically starts to push it underground. In this case you could automatically destroy constraint or dynamically edit linear limit. For example if distance between heli and vehicle is 20 meters then constraint limit is 2 meters, so "lift off" will start at 22 meters. If distance between them get's shorter, like 18 meters you could adjust limit to be 18 meters too, so heli could technically just "land" on top of vehicle with rope attached. As heli start to lift off, distance between them becomes more than 20 meters, you immediately switch limit to 2 meters and at 22 vehicle will be pulled into the air.

                            Did you found what was the reason for crash?
                            Thanks for the input, I was thinking of doing exactly that already.

                            Regarding the crash: The way I had it set up before, the helicopter actor had a constraint component and cable component already added to it, and just had the targets changed as required. I swapped it out so that the constraint and cable are created dynamically when required, then deleted (as opposed to being made invisible before) when no longer required, rinse and repeat. That fixed the crash, so I assume that PhysX didn't like the constraint being connected and disconnected multiple times in a row.

                            Comment


                              #15
                              Ohh, good to know, this should be a bug.
                              Youtube Channel

                              Comment

                              Working...
                              X