GameMaker Help with Rope and physics_joint_set_value

V

vreetech

Guest
Hey

I've been messing with some GMS2 physics but have come into a problem which I hope someone can help with.

I've a basic side on platformer and can tether utilizing physics_joint_rope_create, which works perfectly well. The problem is I'm wanting "wind" and "unwind" the rope, which I'm attempting to do with using physics_joint_set_value. It's behaving strange however and I cant get my head around it. Pressing "W" calls this:

CurrentLength = physics_joint_get_value(Grapple, phy_joint_max_length);
physics_joint_set_value(Grapple, phy_joint_max_length, CurrentLength - 0.00001);

It seems to be altering the decimal point and putting 000's on it, rather than what I'm trying to do. Assume this is rounding, data type, math fail on my part.

Any help would be appreciated.

Cheers!
 
V

vreetech

Guest
Bump. Any advice on this? Tried rounding and still no dice. Setting to say 150 puts it to 1500. Stumped.
 

Lucas3DCG

Member
I just had same problem with this and after reading this, I found a culprit. If anyone still has problems this is what you have to be aware:
When setting phy_joint_max_length with physics_joint_set_value be sure to multiply it with your Pixels To Meters (Room Settings)

GML:
global.physics_Pixels_To_Meters = 0.1;

physics_joint_set_value(joint_id, phy_joint_max_length, desired_length * global.physics_Pixels_To_Meters);
I didn't find any way to check Pixel To Meters room variable through code, but you can set it through code when you create it with function Physics_world_create(pixeltometrescale);
 
Top