GMS 2 Collision offset?



Hi, this would be my first comment on this forum (and my first time using GMS). Nice to meet you all. :)

So... Right now i'm trying to make a platformer game, checked a few videos and ended with this:

// Character variables.

Gravity = 1;
Speed_Movement = 5;
Speed_Jump = 7;
and this...
// Inputs.

Mov_Left = -keyboard_check(vk_left);
Mov_Right = keyboard_check(vk_right);
Mov_Jump = keyboard_check_pressed(vk_space);

// Horizontal movement.

Dir = Mov_Left + Mov_Right;
hspeed = Dir * Speed_Movement;

    if (place_meeting(x, y+1, object_1))
        vspeed = 0;
        if(vspeed < 10)
            vspeed += Gravity;
I just wanted to have horizontal movement with vertical collisions til' now, so please ignore the lack of horizontal collisions, my main concern right now is this little offset when the player collides with "object_1" (floor) when he falls:

(Blue = Player / Red = Ground)

Is this supossed to happen or am I doing something wrong? I'd really appreaciate some help, thanks for checking my thread.


Your code sets vspeed to 0 once the object has collided with something. It doesn't do anything to move the object out of the collision. In any case, your object is falling with speed n and as such will stop anywhere from 0 to n pixels inside the ground.