• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!
  • Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

SOLVED Room Wrap & Physics

B

BigCat

Guest
Building a game with flappy bird style physics. IE: Each spacebar press causes a single flap. If the left key is held when a flap occurs, the instance adds momentum at a 135 degree angle. Or, if holding the right key - a single flap adds momentum at a 45 degree angle. With gravity turned on - this should create a look/feel of the instance flying left and/or right, or possibly hovering if it's simply flapping without a direction key selected. This game also uses screen wrap.

Everything seems to work fine - until room physics are turned on. With physics turned on - suddenly the room wrap doesn't function, nor does "motion_add". If I turn off room physics - the room wrap works properly, and motion_add behaves as expected - but without the effects of gravity obviously.
I'm really confused by this. Do I need to turn off room physics and "fake" gravity with each individual object/character?
 
Last edited by a moderator:
B

BigCat

Guest
...and as usual - 3 minutes after I post a question, I figure it out myself. *Facepalm*

SOLUTION: Turn off room physics and apply physics to object movement via built in instance variables.
 
Also another way to do it, add this code to the outside room event for your object

GML:
/// Wrap in both directions
if (phy_position_x > room_width) {
    phy_position_x = 0 - (phy_position_x - room_width);
} else {
    if (phy_position_x < 0) {
        phy_position_x = room_width - phy_position_x;
    }
}

if (phy_position_y > room_height) {
    phy_position_y = 0 - (phy_position_y - room_height);
} else {
    if (phy_position_y < 0) {
        phy_position_y = room_height - phy_position_y;
    }
}
 
Top