Avram
Member
Hi all,
I have a player object that walks on a solid platform (obj_platform) but will bounce up on a bouncy block (obj_bouncyblock). Vertical movement is determined by vsp. Bouncespeed is set to 8. Here's the slightly modified Shaun Spalding code:
My problem is that if the player hits their head on a platform they rise through it when I'd rather have platforms above act as a barrier. I've tried while loops, for-next loops, a whole bunch of if statements, but cannot figure it out. Anyone got any ideas?
I have a player object that walks on a solid platform (obj_platform) but will bounce up on a bouncy block (obj_bouncyblock). Vertical movement is determined by vsp. Bouncespeed is set to 8. Here's the slightly modified Shaun Spalding code:
GML:
//bouncy blocks
bouncing_block = instance_place(x,y+16,obj_bouncyblock); //touching bouncing platform?
if bouncing_block != noone
{
if (bouncing_block.y > y+16)//is player 16px above bouncy block?
{
if !instance_place(x,(y-32),obj_platform) //check if player is about to hit their head on a platform
{
vsp = -(3 * bouncespeed);
}
}
}
if (vsp < 15) vsp += grav; //fall, but don't go too fast
if (place_meeting(x,y+1,obj_platform)) //are we on a platform?
{
vsp = 0; //don't fall
}
y += vsp; //move vertically