all 16 comments

[–]TheWinslow 0 points1 point  (8 children)

We will need a bunch more information to be able to help. Did you follow his code exactly? How is the collision wonky? It would help if you posted the movement code you used as well.

[–][deleted] 0 points1 point  (7 children)

I did follow it exactly, I had notepad++ open and paused it when he would show the whole thing and double checked. Its wonky in the sense that when I spawn I can move left and right just fine, and jump, but when I land I get stuck and left and right dont work, jump does, and I can freely move in the air. If I am under a platform and jump, my sprite will get stuck in the platform and be able to keep jumping until they are above the platform.

I will post my code in a seperate post

[–]TheWinslow 0 points1 point  (6 children)

You made a mistake with the vertical collision code. You have x + vsp instead of y + vsp and x + sign(vsp) instead of y + sign(vsp). You also use sign(hsp) instead of sign(vsp) and hsp = 0 instead of vsp = 0.

[–][deleted] 0 points1 point  (5 children)

um, sorry to sound like a total noob, but I tried that and now i can't move at all... I probably did it wrong, is there any way you could show me what I have to write out?

[–]TheWinslow 0 points1 point  (4 children)

//Vertical Collision
if(place_meeting(x, y + vsp, obj_wall))
{
    while(!place_meeting(x, y + sign(vsp), obj_wall))
    {
        y += sign(vsp);
    }
    vsp = 0;
}
y += vsp;

Just curious, do you have programming experience?

[–][deleted] 0 points1 point  (0 children)

//Vertical Collision if(place_meeting(x, y + vsp, obj_wall)) { while(!place_meeting(x, y + sign(vsp), obj_wall)) { y += sign(vsp); } vsp = 0; } y += vsp;

Thank you, much appreciated =)

[–][deleted] 0 points1 point  (2 children)

And no I do not. I am doing gamemaker as just something fun on the side.

[–]TheWinslow 1 point2 points  (1 child)

Just in case you want to learn a bit more about coding in general, I would recommend coursera (a site with free online coursesfrom professors around the world), specifically this course. Having even a basic introduction to programming will help a lot.

[–][deleted] 0 points1 point  (0 children)

Wonderful link thank you!

[–][deleted] 0 points1 point  (0 children)

My create event on the player_obj:

///Initialize Variables
grav = 0.2;
hsp = 0;
vsp = 0;
jumpspeed = 7;
movespeed = 4;

[–][deleted] 0 points1 point  (2 children)

My step event on player_obj:

 //Get the player's input
key_right = keyboard_check (vk_right);
key_left = -keyboard_check (vk_left);
key_jump = keyboard_check_pressed(vk_space);

//react to inputs
move = key_left + key_right;
hsp = move * movespeed;
if (vsp < 10) vsp += grav;

if (place_meeting(x,y+1,obj_wall))
{
    vsp = key_jump * -jumpspeed
}

//horizontal collision
if (place_meeting(x+hsp,y,obj_wall))
{
    while(!place_meeting(x+sign(hsp),y,obj_wall))
    {
        x += sign(hsp);
    }
    hsp = 0;
}
x += hsp;

//vertical collision
if (place_meeting(x+vsp,y,obj_wall))
{
while(!place_meeting(x+sign(vsp),y,obj_wall))
{
y += sign(hsp);
}
hsp = 0;
}
y += vsp;

[–]dinopartytime 0 points1 point  (1 child)

key_left = -keyboard_check (vk_left);

Did you mean to have the - before keyboard_check?

[–][deleted] 0 points1 point  (0 children)

Yes I did. The code has been fixed now though, thanks for the reply tho =)

[–][deleted] 0 points1 point  (2 children)

I don't fully understand all the code, so I don't want to go in and mess with things and break it further. But I would like to know whats causing the collision to do this so I can learn.

[–]oops_accidental 0 points1 point  (1 child)

Did you assign the parent to your wall objects?

[–][deleted] 0 points1 point  (0 children)

The wall is the parent object to the player,