# Tile Collision not working

Discussion in 'Programming' started by Squirtle Plays, Mar 17, 2019.

Tags:
1. ### Squirtle PlaysMember

Joined:
Mar 17, 2019
Posts:
6
So I need help with Tile collision I'm using Shaun Spalding's Tile collision code (since I'm not good at coding) and I have physics on for jumping and falling but my character is falling through the floor PS horizontal collision is working and this is my code for step

var bbox_side;

key_right = keyboard_check(vk_right);
key_left = keyboard_check(vk_left);

hsp = (key_right - key_left) * 4;

//Horizontal Collision
if (hsp > 0) bbox_side = bbox_right; else bbox_side = bbox_left;
if (tilemap_get_at_pixel(tilemap,bbox_side+hsp,bbox_top) != 0) || (tilemap_get_at_pixel(tilemap,bbox_side+hsp,bbox_bottom) != 0)
{
if (hsp > 0) x = x - (x mod 32) + 31 - (bbox_right - x);
else x = x - (x mod 32) - (bbox_left - x);
hsp = 0;
}
x += hsp;
//Vertical Collision
if (vsp > 0) bbox_side = bbox_bottom; else bbox_side = bbox_top;
if (tilemap_get_at_pixel(tilemap,bbox_left,bbox_side+vsp) != 0) || (tilemap_get_at_pixel(tilemap,bbox_right,bbox_side+vsp) != 0)
{
if (vsp > 0) y = y - (y mod 32) + 31 - (bbox_bottom - y);
else y = y - (y mod 32) - (bbox_top - y);
vsp = 0;
}
y += vsp;

2. ### TheouAegisMember

Joined:
Jul 3, 2016
Posts:
6,280
Why are you using physics? It's incompatible with your collision code.

Joined:
Mar 17, 2019
Posts:
6
oh

4. ### Squirtle PlaysMember

Joined:
Mar 17, 2019
Posts:
6
that was never mentioned in the video sorry I thought it was universal