• 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!

GameMaker Collision offset?

L

Lolimancer

Guest
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:

Code:
// Character variables.

Gravity = 1;
Speed_Movement = 5;
Speed_Jump = 7;
and this...
Code:
// 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;
    }
    else
    {
        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.
 

TheouAegis

Member
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.
 
Top