• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GameMaker Weird behaviors of rope joints

D

DDanny

Guest
Hi,

I'm currently using a rope joints (physics_joint_rope_create) to connect multiple "rope segments" and create a rope. This method is very popular for making a rope and so far it's been working fine for me - 2 objects connected with a rope will move together in a believable fashion.

However, there's this weird behavior of the joints when 2 of them get slightly separated through a wall (which they were supposed to collide with), one of them would fall down, as if it was connected to nothing. Illustrated below:

Normal rope:
upload_2018-10-8_6-27-7.png

Collide with ground:
upload_2018-10-8_6-27-39.png

Weird stuffs (pt. 1)
upload_2018-10-8_6-28-26.png
Note the the black lines are simply drawn between 2 segments, they have no physical properties.

Weird stuffs (pt. 2)
upload_2018-10-8_6-29-44.png
The box has the same density as any rope segment.

Just for reference, here's my code that connects the segment:
Code:
var offset = 0;
var maxLength = 0.1;

var    nextRope = instance_create_layer(x, y, "instances", obj_rope);
var heli = instance_nearest(x, y, obj_heli);
var attach = physics_joint_rope_create(heli, nextRope, heli.x, heli.y, nextRope.x, nextRope.y, maxLength, false);
physics_joint_set_value(attach, phy_joint_max_length, maxLength);

with (nextRope) {
    lastRope = heli.id;   
}

repeat(100) {
    offset+=0.1;
    var currentRope = nextRope;
    nextRope = instance_create_layer(x, y + offset, "instances", obj_rope);
    
    var link = physics_joint_rope_create(currentRope, nextRope, currentRope.x, currentRope.y, nextRope.x, nextRope.y, maxLength, false);
    physics_joint_set_value(link, phy_joint_max_length, maxLength);
    
    with (nextRope) {
        lastRope = currentRope;   
    }
}

var box = instance_nearest(x, y, obj_box);
attach = physics_joint_rope_create(nextRope, box, nextRope.x, nextRope.y, box.x, box.y, maxLength, false);
Really hope someone can put out some thoughts and opinions on this so I can have a direction to fix this problem. Thinking about actually restricting the movement of the segments from eachother by code but that could potentially ruin the integrity of the physics system.
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
Slightly off topic (but could be related), why are you creating 100 rope instances and joints???? Looking at the screenshots, it seems to me that you could easily get away with much fewer, like 20 or so....I'm wondering if having so many connected like that is maybe causing the Box2D library to freak out a bit....
 
Top