• 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 Help with realistic physics working on multiple objects.

M

Maxx_

Guest
Sorry for the title being so confusing, so to fix that issue I'll explain my issue, I'm relatively new to GM 1.4, and I was watching Shaun Spaudling's tutorial on basic platformer movement physics, and heres my code:
///Movement Variables
//Get Player's Input
key_right = keyboard_check(vk_right);
key_left = -keyboard_check(vk_left);
key_jump = keyboard_check_pressed(vk_space);

//Reaction
move = key_left + key_right;
hsp = move * movespeed;
if (vsp < 10) vsp += grav;

if (place_meeting(x, y + 1, obj_forestfloor))
{
vsp = key_jump * -jumpspeed
}

//Horizontal Collision
if (place_meeting (x+hsp, y, obj_forestfloor))
{
while(!place_meeting(x+sign(hsp),y, obj_forestfloor))
{
x += sign(hsp);
}
hsp = 0
}
//Vertical Collision
if (place_meeting(x, y + vsp, obj_forestfloor))
{
while(!place_meeting(x,y + sign(vsp), obj_forestfloor))
{
y += sign(vsp);
}
vsp = 0
}
x +=hsp;
y += vsp;
The beginning isnt too important, but after Vertical Collision and Reaction, I need help that these physics don't only apply when standing on or about to hit "obj_forestfloor" and instead say that my player was about to land on something like "obj_castlefloor". I'd be happy to clarify anything if anyone needs it.
 
Top