• 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 Applying forces to a main character

L

lindens

Guest
Just looking for some clarification on if i'm doing this correctly.
My player has normal movement attributes: a velocity vector, max_velocity, accel, etc.
Code:
// Move, creates the desired velocity based on player input
player_move();

// Apply forces, 20 being the player's density, F = MA right?
var x_force = (velocity[@ 0] - phy_speed_x) * 20;
var y_force = (velocity[@ 1] - phy_speed_y) * 20;
physics_apply_force(phy_position_x, phy_position_y, x_force, y_force);
It works very nicely for the player.
However, for other instances, say an enemy with a density of 2, multiplying by 2 makes him spazz out violently and when i remove that * 2, the enemy moves normally.

EDIT: just discovered the phy_mass variable, works nicely as well
 
Last edited by a moderator:
Top