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

GML Getting stuck in the floor in walls

U

Unofficial Horse Extract

Guest
In Game Maker Studio 1.4.1772, I'm following this tutorial on how to make a sonic game in game maker and by the end of the first video I am getting stuck in the floors when I jump on them and stuck into walls while walking into them. Part of the issue may be my confusion with collision and origin mapping for my sprites, since I'm using the adventure sprites instead of the classic sprites (The sprites are based off multiples of 5 instead of 2 and are supposed to go a bit into the ground with the front layer). There are only two used objects, Sonic and collidable, a script, a room, and 6 sprites total to inspect so the program hopefully wouldn't be too confusing for outside eyes.

before jump:
upload_2018-1-1_3-44-7.png
after jump:
upload_2018-1-1_3-44-32.png

Here is the code I am using right now:
script: drawUser()
Code:
draw_sprite_ext(sprite_index, image_index, round(x), round(y), image_xscale, image_yscale, image_angle, image_blend, image_alpha);
Sonic (object): Create:
Code:
acceleration = 0.1;
velocity = 0;
MAXSPEED = 10;
ground = false;
availableJumps = MAXIMUM_JUMPS - 1;
(MAXIMUM_JUMPS is a macro value I'm using to try to manage having a single, double, or triple jump.)

Step:​
Code:
///movement
if keyboard_check(vk_left) && !place_meeting(x+(abs(velocity)*-1)-1,y, collidable)
{
    velocity -= acceleration*2;
    image_xscale = abs(image_xscale);
}
if keyboard_check(vk_right) && !place_meeting(x+abs(velocity)+1,y, collidable)
{
    velocity += acceleration*2;
    image_xscale = -abs(image_xscale);
}
if ((velocity > 0 && place_meeting(x+abs(velocity)+1,y, collidable)) || (velocity < 0 && place_meeting(x+abs(velocity)+1,y, collidable))) || (velocity > -acceleration && velocity < acceleration)
    velocity = 0;

if velocity > 0
    velocity -= acceleration;
else if velocity < 0
    velocity += acceleration;

    //speed cap
    if (abs(velocity) > MAXSPEED)
        velocity = MAXSPEED*sign((velocity));
    x += velocity;
   
    //gravity
    if place_meeting(x, y + vspeed + 1, collidable, )
    {
        ground = true;
        gravity = 0;
    }
    else
    {
        ground = false;
        gravity = 0.25;
        if vspeed > 8
            vspeed = 8;
    }
   
    //jumping
    if(availableJumps > 0 && keyboard_check_pressed(ord('Z')))
    {
        vspeed = -7;
        availableJumps -= 1;
    }

//animation
if(ground)
{
    if velocity == 0
        sprite_index = Sonic_idle;
    else if abs(velocity)>0
        sprite_index = Sonic_walk;
    else
    {
   
    }
    image_speed = 0.2 + abs(velocity/20);
    availableJumps = MAXIMUM_JUMPS;
}
else
{
    sprite_index = Sonic_jump;
    image_speed = 0.2 + abs(velocity/20);
}
Collision:​
Code:
move_contact_all(direction, 40)
vspeed = 0;
(it was 16 in the video, but I kept messing with it because sonic was in the ground.)

Draw:​
Code:
drawUser();
Download Here
 
Last edited by a moderator:

Bingdom

Googledom
See this

Also, I recommend watching the video again. That way, you can see where you went wrong and learn from there.
 
U

Unofficial Horse Extract

Guest
i'm sorry that I broke the guidelines. How do I delete the post.
 

Bingdom

Googledom
There's no need to delete it ;). Just add the code that's causing the problem to the original post. Maybe someone will be more willing to help out.
 
U

Unofficial Horse Extract

Guest
After rereading the only thing I forgot was the version number, Game Maker Studio 1.4.1772, but I guess I might look at other sections to see where this would be better placed any ways.
 
U

Unofficial Horse Extract

Guest
I updated it. I'm sorry if I'm wasting your New Years Day.
 
U

Unofficial Horse Extract

Guest
I think the issue may be with some sprites the top, bottom, left, and right collision are changing between sprites, because of how Dimps changed the ratio of sprite size between animations in Sonic Advance. I placed the origin below the bottom collision of each used sprite so Sonic wouldn't get stuck when he landed, but I don't think the other sides are accounted for. Changing the collidable to solid seemed to stop the floor issue and most of the wall issue, but this causes two problems.
  1. I remember learning that moving solid objects is straining to computers, so I can't add moving platforms with the parent collidable.
  2. Getting stuck in corners or in walls still happens, but you can usually jump out of it.
 
U

Unofficial Horse Extract

Guest
The download link has been updated with a build with better collision boxes and the changes mentioned.
There are two remaining glitches I am working on right now.
  1. Whenever you jump against a wall or ceiling, you can infinitely jump by button mashing.
  2. Whenever you stop walking directly left of a wall, you can only turn around.
I don't get where these glitches came from or how to do this without solids for better flexibility.
 
Top