Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question How would you make a "Muscle"? (a line pulling 2 cubes together)

Discussion in 'Physics' started by Linkerbrain, May 26, 2020.

  1. Linkerbrain


    Mar 27, 2020
    Hello thank you for reading my post.


    I am working on a simulation project, where we have artificial creatures moving around. The creatures consist of cubes, and are currently linked together using configurable joints. To make the creatures move, I made an implementation of neural networks, which all works well. What doesn't work well is the movement system.

    Currently, to simulate some sort of simplified muscle, I apply AddRelativeTorque() on the cube, which adds a rotational force. However this doesn't make for the results I am looking for, since this makes the rotational force also rotate the rest of the body, even when the rotating block can't rotate itself.

    The problem
    I can't figure out a way to simulate/make a line between two cubes, which can contract pulling the cube it is attached to. I made this illustration to show what I mean:

    I want the black line to be able to retract to a certain length with a force. It should pull the blue (and the red a little bit) blocks. If the block is obstructed it should just move as far as it can.

    Do you know a way to implement a system like this? I would love your help, even if it is just an idea! It also doesn't exactly has to match the image above, I just have something like this in mind currently. I am stuck on this problem for a week now, and it is driving me mad.

    Thank you,