How to make a towing mechanic

Hey everyone, So i’m making a game where the player is a spaceship and to collect items he needs to use a tow cable. Now, Here is an example: Solar Jetman: Hunt for the Golden Warpship - NES Gameplay - YouTube
You can see the spaceship towing the item and the item swings, I tried doing this with hinge joint but i had to make the spaceship’s rigidbody kinematic, but then the spaceship can’t move. Can anyone tell me how to make this mechanic like in the video?

I suggest you take a look at this Video Tutorial about Hinge Joints

it is about 2d joints but it concept is the same with 3d.

Also, I highly recommend you to check out other joint related videos too

as @ceandros mentioned, physics joints are perfect for your case but learning them is need a lite bit more attention. So go ahead and educate yourself :slight_smile: Good luck

Rope physics are tough.
A simpler option could be to make a “tractor beam”.
That would involve adding forces to the towed object’s rigidbody towards your spaceship.

public class TractorBeam : MonoBehaviour
    public Transform SpaceShip;
    public Rigidbody TowedObject;

    public ForceMode ForceMode = ForceMode.Force;

    public float MaxForce = 15;
    public float MinForce = -5;
    public float MaxRange = 10;
    public float MinRange = 5;

    private void FixedUpdate()
        var direction = SpaceShip.transform.position - TowedObject.position;
        var distance = direction.magnitude;
        var range = Mathf.Lerp(MinRange, MaxRange, distance) / MaxRange;
        var force = Mathf.Lerp(MinForce, MaxForce, range);

        TowedObject.AddForce(direction.normalized * force, ForceMode);

A hinge joint is perfect for this, however you do not need to make the ship kinematic, and making it kinematic won’t prevent you from moving it.

If you want the towed object to affect the ship (for example to weigh it down, or to move it when it swings), the ship cannot be kinematic.

Simply use Rigidbody.velocity or Rigidbody.AddForce to move your ship, and the physics will take care of the rest. Look for “dynamic rigidbody control unity” for scripts to do that, but simply using AddForce in the directing of the input will be enough. Increase the weight of the ship and decrease the weight of the towed object if it’s affecting you too much.

If you want the towed object to never affect the ship, you have multiple options. Either:

  • reduce the weight of the towed object very close to 0
  • set the joint so it is attached to a world point, and move that point to follow the ship
  • set the ship to kinematic, and use MovePosition to move it around. Unfortunately you’ll pass through walls, so you’ll have to check for that using raycasts before moving

I just started working on the same thing, a tractor-beam towing setup, which is for a 3D space-shooter game. I have been trying various methods to find one that looks realistic, and will try the TractorBeam script mentioned here. I will post the method that I end up using soon, but if it helps anyone, here is a tractor-beam animation that I use in Unity. It makes a realistic looking 2D tractor-beam using a texture animation.
TractorBeamAnim_PNG 91 images