Hi guys ! I'm pretty new in GML so I'm pretty sure that my bug is easy to fix but hey, i'm a noob !
So, I looked a youtube tutorial for the movment of my character :
Script PlayerMovement()
Alright so with this code, there is 2 major problems :
* I can be block if my character hits a corner. It that case, my character don't respond to any of my command and he's stuck in the wall. I think it's because he tries to do both collision vertical and horizontal. Not sure about that but I think thats the problem.
* Sometimes (not a lot of time), I have a very weird bug. Let's imagine i'm just under a wall. If I jump and I hit perfectly the pixel of the corner of the wall above me, i'm going to teleport instantly my character backdown. It's like, I jump and just after hiting the corner, I'm exactly where I was before the jump. Very weird and I just saw an ennemy (because I use the same script for collisions for my ennemies) doing it but in an horizontal way : He hit the corner from the right and got teleported to the left (from a wall).
Alright, if you have any idea how to help me, it could save my game !
Sorry for the english, i'm learning it too
See ya,
Zaksley.
So, I looked a youtube tutorial for the movment of my character :
Script PlayerMovement()
Code:
//MOVEMENT PLAYER
//Calculate Movement
var move = checkKeyboard_Right - checkKeyboard_Left;
hsp = move * walkspeed;
vsp += grv;
//Jump from floor
if ( (place_meeting(x, y+1, obj_wall)) && (checkKeyboard_Jump) )
{
vsp = -8;
}
//Double Jump
if (!place_meeting(x, y+1, obj_wall) && double_jump) && checkKeyboard_Jump
{
vsp = - 8;
double_jump = false;
}
//Vertical Collision
if place_meeting(x+hsp, y, obj_wall)
{
while (!place_meeting(x + sign(hsp), y, obj_wall))
{
x += sign(hsp)
}
hsp = 0;
}
//Horizontal Collision
if place_meeting(x, y + vsp, obj_wall)
{
while (!place_meeting(x, y + sign(vsp), obj_wall))
{
y += sign(vsp)
}
if !place_meeting(x, y+vsp, obj_ceiling)
{
//Reset Double Jump
if !double_jump double_jump = true;
}
vsp = 0;
}
//Movement
x += hsp;
y += vsp;
* I can be block if my character hits a corner. It that case, my character don't respond to any of my command and he's stuck in the wall. I think it's because he tries to do both collision vertical and horizontal. Not sure about that but I think thats the problem.
* Sometimes (not a lot of time), I have a very weird bug. Let's imagine i'm just under a wall. If I jump and I hit perfectly the pixel of the corner of the wall above me, i'm going to teleport instantly my character backdown. It's like, I jump and just after hiting the corner, I'm exactly where I was before the jump. Very weird and I just saw an ennemy (because I use the same script for collisions for my ennemies) doing it but in an horizontal way : He hit the corner from the right and got teleported to the left (from a wall).
Alright, if you have any idea how to help me, it could save my game !
Sorry for the english, i'm learning it too
See ya,
Zaksley.