Velocity
Member
Hey,
So I'm making a fighting game and my character is getting stuck in the walls.
I set my player object mask as a sprite, so that the sprites wouldn't change and stick me into the wall.
Also, I made sure that sprite had an odd number of pixels and set the origin to the exact pixel horizontally in the middle of the sprite.
Plus, I also used Shaun Spalding's video tutorial about platformer basics, and set a collision checker preventative measure against getting stuck in the walls.
I even used another solid object (placed over the wall object) and used a normal collision event between that and the player object.
I'm wondering if it's because Game Maker isn't recognising a variable I made global, called "global.playerspeed" instead of hsp.
By the way, I'm making my game with someone else's code. He also had a couple of problems with getting stuck in the walls, but only the opponent used to get stuck when he moved back into the wall after getting hit. I also changed his sprites to my new ones.
So, here's my code:
//Horizontal collision to avoid getting stuck in wall
if (place_meeting(x + global.playerspeed, y, obj_player_parent))
{
while (!place_meeting(x+sign(global.playerspeed),y,obj_player_parent))
{
x += sign (global.playerspeed) ;
}
global.playerspeed = 0;
}
So I'm making a fighting game and my character is getting stuck in the walls.
I set my player object mask as a sprite, so that the sprites wouldn't change and stick me into the wall.
Also, I made sure that sprite had an odd number of pixels and set the origin to the exact pixel horizontally in the middle of the sprite.
Plus, I also used Shaun Spalding's video tutorial about platformer basics, and set a collision checker preventative measure against getting stuck in the walls.
I even used another solid object (placed over the wall object) and used a normal collision event between that and the player object.
I'm wondering if it's because Game Maker isn't recognising a variable I made global, called "global.playerspeed" instead of hsp.
By the way, I'm making my game with someone else's code. He also had a couple of problems with getting stuck in the walls, but only the opponent used to get stuck when he moved back into the wall after getting hit. I also changed his sprites to my new ones.
So, here's my code:
//Horizontal collision to avoid getting stuck in wall
if (place_meeting(x + global.playerspeed, y, obj_player_parent))
{
while (!place_meeting(x+sign(global.playerspeed),y,obj_player_parent))
{
x += sign (global.playerspeed) ;
}
global.playerspeed = 0;
}