P
phism
Guest
I know this has been asked multiple times in the past, but I couldn't find a solution on how to make a one way platform that works for the player and other objects, so I made my own.
I still haven't found mayor problems with it, except two:
1. Everytime the player object lands on the platforms, it switches its animation between Airbone and Idle really fast two or three times before staying on the idle animation, it's barely noticeable but it's there.
2. When the player is touching two platforms at the same time, he just falls off from the platform he's standing on, this is a common problem, but it can be avoided positioning the platforms in the right places.
This is my collision code:
And this one is the switching sprite code:
Basically, I can't figure out the animation flickering so I can't fix it.
EDIT: I wanted to post a gif to show you guys the problem, but I dont have the permissions.
I still haven't found mayor problems with it, except two:
1. Everytime the player object lands on the platforms, it switches its animation between Airbone and Idle really fast two or three times before staying on the idle animation, it's barely noticeable but it's there.
2. When the player is touching two platforms at the same time, he just falls off from the platform he's standing on, this is a common problem, but it can be avoided positioning the platforms in the right places.
This is my collision code:
Code:
//Vertical collisions.
if (place_meeting(x,y + vspd,objStepable)) and ((((instance_place(x,y + vspd,objStepable)).y) - 16) >= (y + 24))
{
while (!place_meeting(x,y + sign(vspd),objStepable))
{
y = y + sign(vspd);
}
vspd = 0;
}
//The player sprite is 48x48 and the platform (objStepable) is 32x32.
Code:
//Animation
if (place_meeting(x,y + 1,objStepable)) and (vspd == 0) //If you are on the ground:
{
image_speed = 0.25; //Use the correct fps for the animations below.
if (sign(hspd) != 0) //...and moving:
{
sprite_index = sprEnemyRun; //Change your sprite.
}
else //...not moving:
{
sprite_index = sprEnemy; //Change your sprite.
}
}
else //If you are in the air...
{
sprite_index = sprEnemyAir; //Change your sprite.
image_speed = 0; //Dont play the animation.
if (sign(vspd) <= 0) image_index = 0 else image_index = 1; //Check if you are going up/down, and change your sprite accordingly.
}
if (hspd != 0) image_xscale = sign(hspd); //Change your sprite direction according to where you are facing.
EDIT: I wanted to post a gif to show you guys the problem, but I dont have the permissions.
Last edited by a moderator: