Last active
September 6, 2016 09:55
-
-
Save kidando/9548048 to your computer and use it in GitHub Desktop.
Game Maker: Studio - [Platformer] [GML] Colliding with Solids Perfectly (Collision with Ground and/or Walls)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// DESCRIPTION: Solves strange collision issues when landing or walking into a solid (ground or wall) for platformers | |
// CREDIT: cantavanda @ gmc.yoyogames.com | |
// URL: http://gmc.yoyogames.com/index.php?showtopic=545531 | |
// USE: Apply this script in Player -> Collides With -> Solid event | |
//CODE: | |
if (!place_free(x+hspeed,y)) | |
{ | |
if (hspeed<=0){move_contact_solid(180,abs(hspeed));} | |
if (hspeed>0){move_contact_solid(0,abs(hspeed));} | |
hspeed=0; | |
} | |
if (!place_free(x,y+vspeed)) | |
{ | |
if (vspeed<=0){move_contact_solid(90,abs(vspeed));} | |
if (vspeed>0){move_contact_solid(270,abs(vspeed));} | |
vspeed=0; | |
} | |
if (!place_free(x+hspeed,y+vspeed)) | |
{ | |
hspeed=0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment