0

I'm making a 2D Platformer game in GMS 2 and I need to make my player face the direction that he was hit from when he dies. How do I sense which side he was hit from? I only need to sense right and left collision. Currently my code looks like this:

if (hp = 0) {
with (instance_create_layer(x, y, layer, obj_player_1_dead)) {
    if (obj_laser_2.x < obj_player_1.x) {
        image_xscale = 0.6
    } else if (obj_laser_2.x > obj_player_1.x) {
        image_xscale = -0.6
    }
}
instance_destroy()

}

hp is my hit points variable. I have instance_destroy(); at the bottom because I am destroying the object and creating a player_dead object.

Everything else works exactly how I want it to. This is the last thing before the game is done. Any help is appreciated. Thanks in advance!

  • I havn't tested it, but the code doesn't look wrong to me. Can you explain me what happens if you run this code? Have you tried debugging it? – Steven Oct 19 '17 at 06:31
  • 1
    Hi. This question is not the right one anymore and the problem got fixed a long time ago with a different question. I think that I lost this one and had to make a new question so the answer to the problem is in there. Sorry. –  Oct 19 '17 at 13:17
  • Ah, that's fine, I could kinda expected one would figure it out after a while. Glad to hear it worked out. – Steven Oct 19 '17 at 13:30

0 Answers0