I'm working on a platformer game using Gamemaker Studio 2. , and currently I'm dealing with implementing platforms (those thin tiles that are able to pass through from the bottom, but remains solid when landing on).
To use some more advanced collision detection, I'm using place_meeting()
instead of the build-in Collision Event.
It's working good and well for a single platform, but when I add multiple, then only the lowest placed platforms will work properly. I'm already aware that the problem lies on the second if-statement in the code below:
if (place_meeting(x, y+mySpeed[1], o_platform) && //If the player collides with a platform
mySpeed[1] > 0 ) //if the player is falling
{
if ((y + 29) < o_platform.y) //if the player's feets are located higher than a platform
{
while !place_meeting(x, y+sign(mySpeed[1]), o_platform)
{
y += sign(mySpeed[1]);
}
mySpeed[@ 1] = 0;
}
}
The problem is likely because it's reading information from any platform. but not the higher platform I'm colliding with. So I should need a check to make sure the program knows it's the same object I'm colliding with.
If this was the build-in Collision Event, I could use the other
statement to get the right instance, but currently I'm using place_meeting
in a step method to collide, and other
would be too broad to use properly. So how would I be able to archieve this?