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

GML [SOLVED] Physics Move at Certain Speed

L

lindens

Guest
I'm having some trouble figuring out how to move my character at a certain speed, for example 2.68 m/s (average jogging speed for a person). I've defined 512 pixels as 1 meter in my physics room (value of 0.1354666667). Since the physics_apply_force uses newtons to move things, i'm not sure what force i need to move an object at 2.68 m/s with basically instantaneous acceleration.

I don't want to just set the phy_speed_x and y because it doesn't interact with other physics objects as well as using the physics_apply_force function (maybe i'm wrong here?).

my max speed is (512 * 2.68) / room_speed and you can assume my velocity is at max speed.
my physics properties are all set to default.
currently the player moves but it accelerates at an abysmally slow rate :(
Code:
// move player
var x_force = (velocity[@ 0] - phy_speed_x); // these forces must be wrong
var y_force = (velocity[@ 1] - phy_speed_y);

physics_apply_force(phy_position_x, phy_position_y, x_force, y_force);

show_debug_message(phy_speed);
EDIT: I was looking more at physics functions and seen that my pixel to meter ratio was calculated wrong. I was using a website to do that calculation but for GameMaker i just had to do 1 / 512 and my problem has been solved! wowzers
 
Last edited by a moderator:
Top