Has anyone successfully built a "muscle" in C3?

Not favoritedFavorited Favorited 0 favourites
  • 6 posts
From the Asset Store
[C2] [C3] Support C3 build service and Android 15+
  • I'm trying to build a "realistic" human arm for a dumb game idea and I can't figure out how to do it in an elegant manner. The idea would be two arm bones, connected to each other with a revolute joint, with a muscle in the middle attached to both bones. This muscle could then expand and contract to drive the bones and either "flex" the arm or straighten it. I've tried a lot of different joints to no avail. There's a good chance I could get something hacked together if I just tell the arm bones to torque in different directions but there's nothing bringing the bones back to a neutral position, which is what I want. Essentially:

    • Press nothing, have the bones be at a right angle to each other
    • Press button A, have the bones straighten out and become almost parallel
    • Press button B, have the bones pull in and be at a very acute angle to each other

    If anyone has any ideas, please let me know. I hope it's more elegant than what I think the answer is, which is constantly applying variable torque to each arm to force a neutral angle and it turns into a PID controller. If it could be not that, I would be grateful. Thanks!

    Tagged:

  • In game development, they do the opposite. Joint positions are calculated using inverse kinematics methods; you can simply ask the AI for the formulas and then plug them into Construct 3 to calculate the position and angle.

    And when you rotate a bone using this method, you then update the muscle’s position, length, and thickness.

    In other words, it’s not the muscle moving the bone, but the muscle adjusting to the bone’s position. But to the player, it will look natural.

  • But I don't know what you're looking for in a game; maybe you just need some kind of bodybuilding clicker.

    Here's a simple example where you move your arms and the muscles contract.

    github.com/igortyhon/Construct3-Simple-Examples/blob/main/Muscle_r476-3.c3p

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Connecting limbs with revolute joints (or limited revolute joints if you want to limit range of motion) and applying torques is a good way to go.

    I've found using a damped spring works well to torque a joint to a specific angle. The damping aspect is just to make it less bouncy.

    torque: -strength*signedAngleDiff(lowerArm.angle, upperArm.angle-160) -damping*lowerArm.physics.anglularVelocity

    Anyways, seems like pretty believable motion. You can even do kipping reps if it's too heavy.

    dropbox.com/scl/fi/2r00jno5uguu3epvdup7y/Physics_arm.c3p

    I'd imaging there's other ways to model an arm/muscle as well.

  • igortyhon I appreciate your help but I'm looking to deliver actual forces/impulses to the arms/legs so as to move stuff around them/deliver blows rather than just move them via IK.

    R0J0hound That is definitely helpful! I'm currently using limited revolute joints and applying torques to much the same effect, just a torque "out" if a button is down and a torque "in" if it's not. What I'd really like, though, is to be able to have an arbitrary array of bones and joints that can connect and then flex and straighten independently without needing to track individual bones. I.e., I am coming to like applying torques to the joints, but I'd like to just have them in some hypothetical "tree" layout and then be able to torque them to their parent bones on their own. A bit like when AI trains to create a jumping or running on-screen robot, a little like the old videos like this (except without AI). Is this just a matter of deciding one bone is the grandparent and then iterating downwards through the bones to set some kind of joints between them all?

    For context, I'd like for the player to assemble a bone structure in a grid, and then it connects the bones with joints automatically and allows for some of them to be flexed and straightened by the player in an understandable way (probably just which ones are at right angles). Any thoughts on not relying on one bone to be the "upper arm" and one to be the "lower arm," but allowing a strange configuration?

  • The arbitrary bone structure is rather easy. just place a bunch of joints, and stretch bones between joints, then just add revolute joints from each joint to any bones overlapping it. Muscles are done with an angular spring between pairs of bones to keep a specific angle between them.

    In this example I set it all up with overlapping sprites and some minimal events to add the joints and setup the initial state of the muscles. I also used a slider to be a runtime control of the joint angles. To control which way a muscle will turn I used the opacity to control that, but it's not the most intuitive imo.

    dropbox.com/scl/fi/fum80cv36619qgvbp407e/torque_muscle_structure.c3p

    Anyways, just an idea. You may want to do the setup in a different way. Also I just used the muscle sprites as a guide for the initial setup. You'd have to do your own thing if you wanted them to stay visually attached while it runs.

    You could also try lineal springs on anchor points (easier said than done), but I find angular springs avoid joints getting stuck inverted better than linear.

Jump to:
Active Users
There are 0 visitors browsing this topic (0 users and 0 guests)