• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM [solved]Collision Event doesnt work on y axis

S

SonicTheHedgehog+123

Guest
I want that my player to restart the room when he is between a vertical platform and the floor.
It works that when he is meeting the floor and the platform he restarts the room. But the strange problem I have is when I am jumping on the y axis of the platform and the platform is moving downwards. The player gets stuck in it. My vertical platform object is solid so this shouldnt happen. The platform.speed is faster than my player speed. I asume it has to do with either two things
1. The vertical object is faster than the player jump so the player gets stuck in it
2. I made a code if the platform is meeting the wall vspeed = -vspeed so when the player does jump it sets -vspeed +vspeed so vspeed = 0

It is a problem that stucks with me.
Open for any given help. :)

Code:
if place_meeting(x,y+1,Beweger)&& place_meeting(x,y+1,Wand)
{room_goto(Restart)}
 

TsukaYuriko

☄️
Forum Staff
Moderator
Marking stuff as solid does not prevent colliding instances from getting stuck in them.

It causes colliding instances to be reset to their previous coordinates.

If said instances then continue to move inside of the solid, having them solid causes those instances to get stuck in the solid.
 
S

SonicTheHedgehog+123

Guest
The room is restarting when the player is between the vertical platform and the floor but when the player jumps and the platform goes down the player gets stuck in it.
Code:
//vertical platform 

Create Event:

vspeed = irandom(5-11)

if (vspeed == 0){
vspeed = 8
}

Step Event:

if place_meeting(x,y,wall)
vspeed = -vspeed;


I hope this helps :)
 

Nidoking

Member
That much looks fine, aside from calling irandom(5-11) instead of the identical irandom(-6), but what is the player object doing? That's where the problem will be.
 
S

SonicTheHedgehog+123

Guest
Here is the movement code of the player:
Code:
Step Event
//Bodenbuffer and Jumpbuffer
bodenbuffer -= 1
if place_free(x,y+1) == false
bodenbuffer = 5

jumpbuffer -= 1
if keyboard_check_pressed(ord("W"))
jumpbuffer = 9;

//movement

hspeed = 0
if keyboard_check(ord("D"))
{
hspeed +=move
image_xscale = 1
}
if keyboard_check(ord("A"))
{
hspeed -=move
image_xscale = -1
}
if jumpbuffer > 0
if bodenbuffer > 0
{
vspeed = -21
jumpbuffer = 0
}

Create Event

bodenbuffer = 0;
jumpbuffer = 0;
 
Last edited by a moderator:

Nidoking

Member
As I think someone said in your previous thread, the problem appears to be that your player is checking for place_free(x, y+1) while the platform is moving down, but before applying gravity. So the platform has already moved on, and your bodenbuffer value drops to 0. You might want to put that check in the End Step event, so the player can jump if they were standing on solid ground (or a platform) at the end of the previous step.
 
S

SonicTheHedgehog+123

Guest
Thank you for pointing out my mistake.
I did put the code below in the End Step Event.
It works better than previously. It works fine when the platform is moving slowly. But when the platform moves fast the player still gets stuck in it.
Code:
if place_free(x,y+1) == false
bodenbuffer = 5

jumpbuffer -= 1

if place_free(x+hspeed,y+vspeed) == false
vspeed=0;
 

Nidoking

Member
Is it possible that the player isn't falling fast enough to end on top of the platform in each step? You might need to set vspeed higher if the player is standing on a platform that's descending that fast.
 
S

SonicTheHedgehog+123

Guest
I did add vspeed when the player is meeting the platform so
the platform wont be faster than my player. And I didnt add so much that the "average" gamer would see it.
So it should be impossible that the player can be stuck on it.

Thank you so much for your help and support :) .
Code:
vspeed += 1.5 
if place_meeting(x,y,Beweger)
{vspeed = +9}
 
Top