Pelican Police
Member
In the manual it says:
"A rope joint is one which is used to join two instances that you want to keep a constant distance apart, no matter what other forces are acting on it. With a distance joint, you can get "joint stretching" where the two fixtures will separate and behave strangely should too much stress be put on the joint, however the rope joint does not do this and will not stretch any further than the maximum defined length."
And yet:
The code if you need it.
Basically just create a new chain instance, and then join it to the previous with a rope join.
"A rope joint is one which is used to join two instances that you want to keep a constant distance apart, no matter what other forces are acting on it. With a distance joint, you can get "joint stretching" where the two fixtures will separate and behave strangely should too much stress be put on the joint, however the rope joint does not do this and will not stretch any further than the maximum defined length."
And yet:
The code if you need it.
Basically just create a new chain instance, and then join it to the previous with a rope join.
GML:
if mouse_check_button_pressed(mb_left)
{
// Position of old chain
var oldChainX = chainInst.x;
var oldChainY = chainInst.y;
// Edge of old chain
var oldChainEndX = oldChainX + lengthdir_x(32,-chainInst.phy_rotation);
var oldChainEndY = oldChainY + lengthdir_y(32,-chainInst.phy_rotation);
// Start pos of new chain (+ gap in between)
var newChainStartX = oldChainEndX + lengthdir_x(1,-chainInst.phy_rotation);
var newChainStartY = oldChainEndY + lengthdir_y(1,-chainInst.phy_rotation);
// Middle pos of new chain
var newChainX = newChainStartX + lengthdir_x(32,-chainInst.phy_rotation);
var newChainY = newChainStartY + lengthdir_y(32,-chainInst.phy_rotation);
// Spawn next chain at middle
var newChainInst = instance_create_depth(newChainX,newChainY,0,obj_Chain);
// Join together
physics_joint_rope_create(newChainInst,chainInst,oldChainEndX,oldChainEndY,newChainStartX,newChainStartY,2,false);
chainInst = newChainInst;
}
Attachments
-
39.6 KB Views: 95
Last edited: