M
McFlyGold
Guest
Hello everyone,
To start this off, I'm using GameMaker Studio 2 and Runtime v2.1.3.189.
So I seem to be having a small collision issue. I'm using a tutorial by Lewis Clark
In part 2 it gets into the collision code. Now he seemed to fix his collision issue in the video, but for me there seems to be a 1 pixel difference in the collisions. Right now I'm just using a simple 16x32 white sprite as the player object since I have no art for the game and just want to make sure things run smoothly first. I'm liking everything so far except this collision problem.
http://imgur.com/ECpW4Qo
Here's a gif that shows that although the blue square meets the walls. you can still see the player poking through. That means that he's overlapping the walls by 1 pixel that I can see. The sprite is using an automatic collision mask set to rectangle. I've tried changing it to custom, but the results are the same. I've also tried extending the mask out by 1 pixel in all directions, but then the sprite doesn't touch the floor or the walls. it stays 1 pixel away!
Here's the collision code I'm using from the video:
I'm not using his squash and squish part of the code. I didn't want my sprite to do that since my character isn't going to do that.
Any ideas as to why my collision seems to be off. Oh yeah, and I've had to place the origin of my sprite to 1 pixel below the sprite or else the player can't move unless you jump first.
Any help is greatly appreciated!
To start this off, I'm using GameMaker Studio 2 and Runtime v2.1.3.189.
So I seem to be having a small collision issue. I'm using a tutorial by Lewis Clark
In part 2 it gets into the collision code. Now he seemed to fix his collision issue in the video, but for me there seems to be a 1 pixel difference in the collisions. Right now I'm just using a simple 16x32 white sprite as the player object since I have no art for the game and just want to make sure things run smoothly first. I'm liking everything so far except this collision problem.
http://imgur.com/ECpW4Qo
Here's a gif that shows that although the blue square meets the walls. you can still see the player poking through. That means that he's overlapping the walls by 1 pixel that I can see. The sprite is using an automatic collision mask set to rectangle. I've tried changing it to custom, but the results are the same. I've also tried extending the mask out by 1 pixel in all directions, but then the sprite doesn't touch the floor or the walls. it stays 1 pixel away!
Here's the collision code I'm using from the video:
Code:
/// @description scr_player_collision()
/// @function scr_player_collision
// Moving Horizontally /////////////////////////////
if(place_meeting(x+hsp, y, obj_wall))
{
while(!place_meeting(x+sign(hsp), y, obj_wall)){ x += sign(hsp) };
hsp = 0;
}
// Apply speed after checks ////////////////////////
x += hsp;
// Moving Vertically ///////////////////////////////
if(place_meeting(x, y+vsp, obj_wall))
{
while(!place_meeting(x, y+(sign(vsp)/10), obj_wall)){ y += (sign(vsp)/10) };
vsp = 0;
if(place_meeting(x, y+1, obj_wall))// Squish when landing
{
grounded = true;
//x_scale = 1.25;
//y_scale = 0.75;
}
}
// Apply speed after checks ////////////////////////////
y += vsp;
Any ideas as to why my collision seems to be off. Oh yeah, and I've had to place the origin of my sprite to 1 pixel below the sprite or else the player can't move unless you jump first.
Any help is greatly appreciated!
Last edited by a moderator: