D
Dogtooth
Guest
I am quite new to Game Maker and have be enjoying it tremendously! But, It seems I have hit my first large bump in the road while working on my collision.
My movement system uses the built-in hspeed and vspeed variables. My goal was to make the ground slippery, to simulate walking on ice. So, what I did was tell the game that when the player presses a key (for instance the right arrow key), it gives them an initial movement speed of 5 in whatever direction I assigned to it (in this case, I would assign it positive five so that the player would move to the right). Then the game would subtract a integer form that number every step until it reached zero, this would create a sliding affect. Using this I was able to create a movement system that works quite well, with little to no issues.
However now that I have moved on to making collisions in the game, (like, "if touch wall, stop" (only if it were that easy)) I have arrived at a plethora of issues. After thinking how I could develop something that feels smooth using my limited knowledge, I came up with his:
I have created individual objects for each side of the wall.
This collision is almost somewhat acceptable, however there are many issues, for example when I hit a outward facing corner I can get stuck in place, or I may be walking along the edge of a wall and when I go past the end of the wall and decide to turn around, I am restricted from moving back any more.
If you have any suggestions on how I might be able to improve on (or fix) this system, I would greatly appreciate the feedback.
My movement system uses the built-in hspeed and vspeed variables. My goal was to make the ground slippery, to simulate walking on ice. So, what I did was tell the game that when the player presses a key (for instance the right arrow key), it gives them an initial movement speed of 5 in whatever direction I assigned to it (in this case, I would assign it positive five so that the player would move to the right). Then the game would subtract a integer form that number every step until it reached zero, this would create a sliding affect. Using this I was able to create a movement system that works quite well, with little to no issues.
However now that I have moved on to making collisions in the game, (like, "if touch wall, stop" (only if it were that easy)) I have arrived at a plethora of issues. After thinking how I could develop something that feels smooth using my limited knowledge, I came up with his:
Code:
///Crappy collision
// player collision
if place_meeting(x,y,obj_horwallright) && (hspeed < 0)
{
hspeed *= 0
}
if place_meeting(x,y,obj_horwallleft) && (hspeed > 0)
{
hspeed *= 0
}
if place_meeting(x,y,obj_vertwallup) && (vspeed < 0)
{
vspeed *= 0
}
if place_meeting(x,y,obj_vertwalldown) && (vspeed > 0)
{
vspeed *= 0
}
This collision is almost somewhat acceptable, however there are many issues, for example when I hit a outward facing corner I can get stuck in place, or I may be walking along the edge of a wall and when I go past the end of the wall and decide to turn around, I am restricted from moving back any more.
If you have any suggestions on how I might be able to improve on (or fix) this system, I would greatly appreciate the feedback.