Quantcast
Channel: Active questions tagged game-maker - Stack Overflow
Viewing all articles
Browse latest Browse all 180

Collision detection makes this game freeze when checking for collisions with multiple platforms

$
0
0

I have one platform which is colliding with the main character, and that works now. But if I want to add two or more platforms, the game sticks. I work with GameMaker Studio now.

// React to inputsmove = key_left + key_right;hsp = move * movespeed;if (vsp < 10)    vsp += grav;if (place_meeting(x, y+1, obj_platform) || place_meeting(x, y+1, obj_platform1)) {    vsp = key_jump * -jumpspeed;}// Horizontal collisionif (place_meeting(x+hsp, y, obj_platform) || place_meeting(x+hsp, y, obj_platform1)) {    while (!place_meeting(x+sign(hsp), y, obj_platform) || place_meeting(x+sign(hsp), y, obj_platform1)) {        x += sign(hsp);    }    hsp = 0;}x += hsp;// Vertical collisionif (place_meeting(x, y+vsp, obj_platform) || place_meeting(x, y+vsp, obj_platform1)) {    while (!place_meeting(x, y+sign(vsp), obj_platform) || place_meeting(x,y + sign(vsp), obj_platform1)) {        y += sign(vsp);    }    vsp = 0;}y += vsp;// Diagonal collisionif(place_meeting(x+hsp, y+vsp, obj_platform) || place_meeting(x+hsp, y+vsp, obj_platform1)) {    while(!place_meeting(x+sign(hsp), y + sign(vsp), obj_platform) || place_meeting(x+sign(hsp), y + sign(vsp), obj_platform1)) {        x += sign(hsp);        y += sign(vsp);    }    hsp = 0;    vsp = 0;}

What mistake am I making? Platform works like it should, but if you jump on platform1, the whole game sticks.

I have been working with Unity and GameMaker for the past two months, so I'm not really good at it.


Viewing all articles
Browse latest Browse all 180

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>