• 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!

Legacy GM Changing Joint Variables!

F

Fernando Jr. Talingdan

Guest
Hey everyone, I'm currently making a character out of ragdoll with the built-in physics of GMS 1.2.1130. I'm having a problem on changing the variables of a certain joint that was created even though I've made a variable within it. I can't seem to find any GMS tutorials about physics that can help me with this.

Code:
var_speed = 0;

hip=self
left_leg=instance_create(x,y,obj_leg)
physics_joint_prismatic_create(left_leg,hip,x,y,0,1,-20,20,true,100,var_speed,true,false);
Here is the creation code for the object

And I want it to change speed whenever I press a button and make the object go up or down, but whenever I do that nothing happens.
 

2Dcube

Member
When you create something, you can give it the value of a variable, like in your case var_speed. You cannot give it the variable itself, so even if you change the variable later, that doesn't affect something you did in the past.

You can get a reference to the joint like this:
Code:
joint = physics_joint_prismatic_create(left_leg, .... etc);
And use that to change something (if it's possible).

Look up Physics Joint Constants.

Unfortunately it looks like phy_joint_speed is "read only", so you cannot change it later.

~~~

To change the speed of physics objects, the most natural way is to exert forces on them (this is how physics works after all). So if you want an object connected to a joint to move up or down, you can give it an impulse in the right direction.

For example
Code:
with(somePhysicsObject)
{
  physics_apply_impulse(x,y,0,100);
}
This will give somePhysicsObject an impulse downwards.
 
F

Fernando Jr. Talingdan

Guest
When you create something, you can give it the value of a variable, like in your case var_speed. You cannot give it the variable itself, so even if you change the variable later, that doesn't affect something you did in the past.

You can get a reference to the joint like this:
Code:
joint = physics_joint_prismatic_create(left_leg, .... etc);
And use that to change something (if it's possible).

Look up Physics Joint Constants.

Unfortunately it looks like phy_joint_speed is "read only", so you cannot change it later.

~~~

To change the speed of physics objects, the most natural way is to exert forces on them (this is how physics works after all). So if you want an object connected to a joint to move up or down, you can give it an impulse in the right direction.

For example
Code:
with(somePhysicsObject)
{
  physics_apply_impulse(x,y,0,100);
}
This will give somePhysicsObject an impulse downwards.

Thanks for the advice about using variables :)
I get what you're trying to say about making the object go up or down by using impulse. But I'm aiming to control the distance of the foot from the body, to make it look like he is crouching.
 
Top