I had a problem with detecting my character's collision with the enemy being detected in 2 ways:
- side by side
- when it (character) jumps into the enemy's head.
I imagine it to be basic, so I figured this question would be not only on the site but also in countless other places.
I researched this site and found related things, but not exactly what I would like:
Getting 2D Platformer entity collision Response Correct (side-to-side + jumping/landing on heads)
But because of this video I got it:
https://www.youtube.com/watch?v=9LbutnLIj84
The game I'm doing is platform, but instead of the character move, it's the platform that moves.
obj_Plataform - Step Event:
if jump==false{
if !place_meeting(x,y+1,obj_Player){
vspeed=-5;
}else{
vspeed=0;
}
}else{
if contJump<20{
contJump+=1;
}else{
jump=false;
contJump=0;
}
}
This is a code that causes the platform to go up when it is not in contact with the player.
And it has a condition for the platform jump (it goes down and the jump
variable becomes true, and after the counter reaches a certain value the jump
variable becomes false).
My problem is that the character can not get into the platform by colliding on the side with it (The character is the white cube):
I thought about using place_meeting
in relation to the x-axis, but the whole platform is just an object (error), because I do not know if it would be possible to move some of dozens of tiles at the same time in the correct way.
Plataform:
I also tried something related in a collision event among those involved, including using the character's x, but nothing worked.
I thought a condition to prevent the platform from walking left while it is colliding with the character.
obj_Plataform - Keyboard Event (left arrow):
x-=10;
Above the current code to move the platform to the left.