J
Jamie572
Guest
Hello! I've been attempting to create vertically and horizontally moving platforms for the small game project I'm working on. The horizontal platforms work perfectly; however, the vertical do not.
When the player jumps on to a vertically moving platform that is currently in an upwards motion, they simply fall through. If the platform is in a downwards motion, they stay on top without any glitchy movement.
I've attempted tweaking the following lines of code in my obj_player and obj_vertical_platform objects, which I believe to be the source of the issue, as well as changing the events in which they take place to Begin and End Step events.
Relevant code of obj_player's Step Event:
obj_vertical_platform's Create Event:
obj_vertical_platform's Step Event:
I am currently using Game Maker: Studio 1.4.1772. I plan on porting my game to Studio 2 once I complete it. If any other code is needed, I will provide it upon request. A preemptive thank you for any and all help!
When the player jumps on to a vertically moving platform that is currently in an upwards motion, they simply fall through. If the platform is in a downwards motion, they stay on top without any glitchy movement.
I've attempted tweaking the following lines of code in my obj_player and obj_vertical_platform objects, which I believe to be the source of the issue, as well as changing the events in which they take place to Begin and End Step events.
Relevant code of obj_player's Step Event:
Code:
// Vertical Collision
if (place_meeting(x, y + vspd, obj_block))
{
while(!place_meeting(x, y + sign(vspd), obj_block))
{
y += sign(vspd);
}
// Reset the variables.
vspd = 0;
}
y += vspd;
Code:
sprite_index = -1;
// Initialize Variables
angle = 0;
angleIncrement = RADIAN; // Defined variable that is 0.0174532...
angleMultiplier = 1;
Code:
// Create motion.
angle += angleIncrement;
var vspd = sin(angle) * angleMultiplier;
// To avoid erroneous checking.
if (instance_exists(obj_player))
{
// Checks if player is not above platform, and masks the platform appropriately.
if ((round(obj_player.y + (obj_player.sprite_height / 2)) > y + vspd) || (obj_player.key_down)) mask_index = -1;
else
{
// Give the object the appropriate mask.
mask_index = spr_vertical_platform;
// If in contact with player, set vspd_carry to vspd.
if place_meeting(x, y - sign(vspd), obj_player)
{
obj_player.vspd = vspd;
}
}
}
// Increment y based upon vspd.
y += vspd;