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

Legacy GM [SOLVED?]Tile Collision

T

Treecase86

Guest
Hey. I've been working on a Sonic engine, and I've encountered a problem. I use tiles as the stage background and foreground. I have separate layers for the background and collision. Problem is, Sonic passes straight through the floor. See below for code.
Code:
///Jumping
var tileGround;
tileGround = tile_layer_find(1,x,y)

if tileGround == true
{
    grounded = true
}

if grounded == false
{
    //if off of ground, apply gravity
    ysp += grav
}
EDIT: I can shoerten it to just
Code:
///Jumping
var grounded;
grounded = tile_layer_find(1,x,y)
if grounded == false
{
    //if off of ground, apply gravity
    ysp += grav
}
could I not?
 

Kahrabaa

Member
could I not?
Yes you could, the second one is better, has one if less.
Problem is, Sonic passes straight through the floor.
Make sure the tiles depth are the same in the editor and your code (1). If they are the same then maybe you forgot to stop sonic when he falls to the ground?
Like this
Code:
///Jumping
var grounded;
grounded = tile_layer_find(1,x,y)
if grounded == false
{
    //if off of ground, apply gravity
    ysp += grav
}
else
{ //if on ground stop vertical / y speed
    ysp=0;
}
 
Top