A
Ateborrachas
Guest
So I was doing that Shaun Spalding tutorial on tile collision and I wrote the script exactly how he wrote, but it didnt work. It was a tile collision system based on origin points and my character had the same point as his. Here is the script I implemented to the step event
the only thing is that I didnt use macros but I dont think that is an issue
GML:
function PlayerCollision(){
var _collision = false;
//Horizontal
if(tilemap_get_at_pixel(collisionMap, x + hSpeed, y))
{
x -= x mod 16;
if(sign(hSpeed) == 1) x += 15;
hSpeed = 0;
_collision = true;
}
x += hSpeed;
//Horizontal Entities
// Vertical
if(tilemap_get_at_pixel(collisionMap, x, y + vSpeed))
{
y -= y mod 16;
if(sign(vSpeed) == 1) y += 15;
vSpeed = 0;
_collision = true;
}
y += vSpeed;
return _collision;
}