I am trying for the first time to use GM's integrated physics (I use version 2.3).
I wanted to create a simple pogo stick.
I created 2 objects:
- One representing the stick, to which I assigned a "Restituition" = 0. This way I set the stick not to bounce if it collides with the terrain.
- A spring object, which must be applied to the base of the stick object. The spring object must be glued to the base of the stick object (so it must follow all its movements). When it collides with the ground, it must transfer the impulse to the stick so that it can jump into the air.
Is the first approach right?
I read the manual and saw that the variables dedicated to GM's integrated physics are different from the "standard" motion variables, and above all they work differently.
Now here are my questions (if my previous reasoning is right):
- To "glue" the spring to the stick I wrote this code (inserted inside the stick object):
But I read in the manual that it is not correct to directly modify the x and y values, since they overwrite the simulation values. Did I understand correctly? If yes, how can I solve this problem?
I also tried to create a joint between the two objects (physics_joint_distance_create), but then I can't move them properly anymore, since it seems that both objects affect the other physical characteristics.
- I can't understand how to transfer all the forces that are activated on the spring that collides with the ground, to the stick, so that the stick (and consequently the spring that is glued to it) moves. Can anyone give me some suggestions about this?
I wanted to create a simple pogo stick.
I created 2 objects:
- One representing the stick, to which I assigned a "Restituition" = 0. This way I set the stick not to bounce if it collides with the terrain.
- A spring object, which must be applied to the base of the stick object. The spring object must be glued to the base of the stick object (so it must follow all its movements). When it collides with the ground, it must transfer the impulse to the stick so that it can jump into the air.
Is the first approach right?
I read the manual and saw that the variables dedicated to GM's integrated physics are different from the "standard" motion variables, and above all they work differently.
Now here are my questions (if my previous reasoning is right):
- To "glue" the spring to the stick I wrote this code (inserted inside the stick object):
GML:
with (obj_spring) {
phy_position_x = other.phy_position_x;
phy_position_y = other.phy_position_y + (other.sprite_height/2); // stick sprite origin is in the middle center
}
I also tried to create a joint between the two objects (physics_joint_distance_create), but then I can't move them properly anymore, since it seems that both objects affect the other physical characteristics.
- I can't understand how to transfer all the forces that are activated on the spring that collides with the ground, to the stick, so that the stick (and consequently the spring that is glued to it) moves. Can anyone give me some suggestions about this?
Last edited: