P
Preston
Guest
Hey all, new here to Game Maker here (studio version). I've been just following some tutorials from Shaun Spalding and a few others. I've got an issue with collisions that's throwing me for a loop (due to inexperience).
TLDR down below.
Basically I took the one way platforms and removed the function of dropping through them. From there I want them to be fully solid not allowing anything to pass through them including my player.
However, what's happening is not the case. If I'm on the moving platform it carries me like normal, and I cannot drop through it like planned. If I fall off of it and collide with the side it will push me like intended, however, if I move left (assuming I fell off the right side of the platform which is also moving right) I just get stuck in mid air as the platform passes through me. Once it's fully through me I drop.
So something is happening when I use an input to move left or right while colliding with the sides of the platform.
Here's a sample of my char just standing on the ground. If I don't move as the platform collides with me it will push me like normal. But I pushed left here, which freezes my char in place while the platform moves through it.
I would like to figure this out before I move forward plans to create different pushing devices (traps).
Here's my players step events (tutorial's basically)
I'm not a programmer so I'm not going to pretend I fully understand everything here, but I get the gist of it.
Here's my platforms:
I don't believe it's a collision mask issue as I spent a lot of time getting everything perfectly centered with all my animations with no collision mask offset from any input.
I want to assume there's something simple I'm missing or have not yet learned/fully understand that will fix my issue. Maybe something along the line of adding a new place_meeting with x's (account for vsp/grav/hsp)? If anyone has an idea I would appreciate it!
Off for the day but will check back later, thanks in advance!
TLDR: Collision with platforms sides freeze my player when an input is issued, allowing the platform to move by while my character is stuck. Need help understanding how to make the sides push my player no matter what.
TLDR down below.
Basically I took the one way platforms and removed the function of dropping through them. From there I want them to be fully solid not allowing anything to pass through them including my player.
However, what's happening is not the case. If I'm on the moving platform it carries me like normal, and I cannot drop through it like planned. If I fall off of it and collide with the side it will push me like intended, however, if I move left (assuming I fell off the right side of the platform which is also moving right) I just get stuck in mid air as the platform passes through me. Once it's fully through me I drop.
So something is happening when I use an input to move left or right while colliding with the sides of the platform.
Here's a sample of my char just standing on the ground. If I don't move as the platform collides with me it will push me like normal. But I pushed left here, which freezes my char in place while the platform moves through it.
I would like to figure this out before I move forward plans to create different pushing devices (traps).
Here's my players step events (tutorial's basically)
Code:
//Get the player's inputs (what is being pushed)
key_right = keyboard_check(vk_right);
key_left = -keyboard_check(vk_left);
key_jump = keyboard_check_pressed(vk_space);
key_down = keyboard_check(vk_down);
//React to inputs
move = key_left + key_right;
hsp = move * movespeed;
if (vsp < 10) vsp += grav;
if (place_meeting(x,y+1,obj_ground))
{
if (key_jump) vsp = -jumpspeed;
}
var hsp_final = hsp + hsp_carry;
hsp_carry = 0;
//Horizontal Collision
if (place_meeting(x+hsp_final,y,obj_ground))
{
while(!place_meeting(x+sign(hsp_final),y,obj_ground))
{
x += sign(hsp_final);
}
hsp_final = 0;
hsp = 0;
}
x += hsp_final;
//Vertical Collision
if (place_meeting(x,y+vsp,obj_ground))
{
while(!place_meeting(x,y+sign(vsp),obj_ground))
{
y += sign(vsp);
}
vsp = 0;
}
var vsp_final = vsp + vsp_carry;
vsp_carry = 0;
y += vsp;
//Animate
if (move!=0) image_xscale = move;
if (place_meeting(x,y+1,obj_ground))
{
if (hsp!=0) sprite_index = spr_walk; else sprite_index = spr_idle;
image_speed = .25;
}
else
{
if (vsp < 0) sprite_index = spr_jump; else sprite_index = spr_fall
image_speed = .25;
}
Here's my platforms:
Code:
//movement
image_speed = .25;
hsp = dir * movespeed;
//Horizontal Collision
if (place_meeting(x+hsp,y,obj_ground))
{
while(!place_meeting(x+sign(hsp),y,obj_ground))
{
x += sign(hsp);
}
hsp = 0;
dir *= -1;
}
x += hsp;
if (instance_exists(obj_player))
{
if place_meeting(x,y-1,obj_player)
{
obj_player.hsp_carry = hsp;
}
}
I want to assume there's something simple I'm missing or have not yet learned/fully understand that will fix my issue. Maybe something along the line of adding a new place_meeting with x's (account for vsp/grav/hsp)? If anyone has an idea I would appreciate it!
Off for the day but will check back later, thanks in advance!
TLDR: Collision with platforms sides freeze my player when an input is issued, allowing the platform to move by while my character is stuck. Need help understanding how to make the sides push my player no matter what.