P
Palocles
Guest
I've just implemented Shun Spaldings code for jump through platforms in my game and my player can jump up through them fine but will not jump back down through them from their own surface.
If I jump a press down while in the air above the platform I will fall through it but if I just press down while on the platform the player object doesn't move.
I expect this is some weird interaction with my movement states which I should be able to allow for but have been unable to so far.
As per the video (
) the platform has a create event to remove the sprite, and a draw event to replace it and the following step event, incorporating some fixes from the video comments.
My intention is for the player to be crouching and press jump to fall through, on a normal block a crouching player will jump if jump_key is pressed.
here is the relevant script for crouch:
The debug messages don't seem to be running either.
Any other code helpful?
Thanks for the help.
If I jump a press down while in the air above the platform I will fall through it but if I just press down while on the platform the player object doesn't move.
I expect this is some weird interaction with my movement states which I should be able to allow for but have been unable to so far.
As per the video (
GML:
if(instance_exists(objPlayer))
{
if((objPlayer.bbox_bottom) > y) || ((objPlayer.key_down))// && (objPlayer.key_jump))
{
mask_index = -1;
}
else
{
mask_index = sprMovingPlatform;
}
}
here is the relevant script for crouch:
Code:
function scrPlayerCrouch(){
show_debug_message("entered Crouch State");
sprite_index = sprPlayerCrouch;
//image_xscale = currentFacing;
//running = 0;
//onGround = 1;
if(image_index >= (image_number -1))
{
image_speed = 0;
}
//should allow player to drop through the block
if (place_meeting(x, y+1, objJumpThruPlatform) && (key_jump))
{
show_debug_message("fall through platform");
scrPlayerGravity();
currentState = playerState.jump;
image_speed = 1;
}
else if(place_meeting (x, y+1, objBlock)&&(key_jump))
{
{
show_debug_message("crouch to jump")
vSpeed = jumpSpd - 0.5;
currentJump ++;
currentState = playerState.jump;
image_speed = 1;
}
}
if (!key_down)
{
currentState = playerState.idle;
image_speed = 1;
}
}
Any other code helpful?
Thanks for the help.
Last edited by a moderator: