OneIsNeverLate
Member
Hello GMC,
I have a physics question, but first, a screenshot:
My game is simple in nature, a platformer using the physics engine: my character can move and jump. When my character is touching the wall and jumping, everything works fine.
But when I jump and in this case hold left to move left, my character would bump his head mid-jump, in between both boxes that form the wall, like this:
(Also, if I would jump over the midsection then hold left, my character would float at the midsection)
when the normal jump height is:
The walls physics collision shape is a box fitting the outline of the sprite and for good measure, I'll paste the characters step code below.
Can anyone help me find the solution? I'll add more info if needed.
OINL
I have a physics question, but first, a screenshot:
My game is simple in nature, a platformer using the physics engine: my character can move and jump. When my character is touching the wall and jumping, everything works fine.
But when I jump and in this case hold left to move left, my character would bump his head mid-jump, in between both boxes that form the wall, like this:
(Also, if I would jump over the midsection then hold left, my character would float at the midsection)
when the normal jump height is:
The walls physics collision shape is a box fitting the outline of the sprite and for good measure, I'll paste the characters step code below.
Can anyone help me find the solution? I'll add more info if needed.
OINL
GML:
move = keyboard_check(ord("D")) - keyboard_check(ord("A"));
jump = keyboard_check_pressed(ord("W"));
push = mouse_check_button(mb_left);
pull = mouse_check_button(mb_right);
pushclick = mouse_check_button_pressed(mb_left);
pullclick = mouse_check_button_pressed(mb_right);
var grounded = physics_test_overlap(x, y+1, 0, o_Floor) or physics_test_overlap(x, y+1, 0, obj);
if(keyboard_check_pressed(ord("R"))) room_restart();
switch (state)
{
case s.normal:
if(mouse_x <= x) image_xscale = -1;
else image_xscale = 1;
if(jump and grounded)
{
phy_speed_y = 0;
physics_apply_impulse(x,y,0,-80);
}
if(move != 0)
{
phy_position_x += move*3;
if(grounded) physics_apply_force(x,y,120*move,0);
else physics_apply_force(x,y,50*move,0);
}
if((pushclick or pullclick) and !psy)
{
psy = true;
image_index = 0;
}
if(psy)
{
if(psycounter == 0 or psycounter == 15 or psycounter == 30) force++;
if(move != 0 and (pull or push) and grounded)
{
if(move == image_xscale) sprite_index = RunPsy;
else
{
sprite_index = RunBackPsy;
effect_create_below(ef_smoke,x,y+5,0,c_ltgray);
}
}
else
{
if(push) sprite_index = PushCharge;
else if(pull) sprite_index = PullCharge;
}
if(psycounter >= maxpsycounter)
{
effect_create_below(ef_smokeup,x+move*15,y-12,0,c_lime);
psycounter = 0;
force = 0;
psy = false;
if(move == 0) sprSwitch(Idle);
else
{
if(move == image_xscale) sprite_index = Run;
else
{
sprite_index = RunBack;
effect_create_below(ef_smoke,x,y+5,0,c_ltgray);
}
}
}
else psycounter++;
}
else
{
if(grounded)
{
if(move != 0)
{
if(move == image_xscale) sprite_index = Run;
else
{
sprite_index = RunBack;
effect_create_below(ef_smoke,x,y+5,0,c_ltgray);
}
}
else sprite_index = Idle;
}
else
{
if(in_range(phy_speed_y, -0.5, 0.5)) sprite_index = Midjump;
else if(phy_speed_y < 0) sprite_index = Jump;
else sprite_index = Fall;
}
}
if(!in_range(phy_speed_x,-8,8)) phy_speed_x = clamp(phy_speed_x,-5,5);
break;
}