• 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.

Legacy GM Physics Engine plane physics

hello, just wanted to ask if there is any way to program 2d side view airplane physics. I'm using Gamemaker's build in physics engine to do this. My current project only has a movable object that can only move left and right by applying force to it. I want it so that the object can fly upwards when object is moving fast enough but I could not make it realistic. And the formulas found on the internet like LiftForce = Coefficient * (AirDensity * PlaneVelocity^2)/2 * WingArea, but it I have no clue how to implement it properly into my game. If there is any way to do this do please tell me, Thank you for reading!
 
C

charat.chan

Guest
While I'm waiting, and hoping, someone will help me with my issue I'll do what I can to help elsewhere.

Ok so you want to be able to fly upwards once you get fast enough. Easy enough in theory but the way you wrote you seem to have already tried a few things. I'll offer what I can and I apologize in advance if this is what you've done already.

So in your create event for the plane you are gonna want to establish some variables like:

Code:
speed = 0;
maxspeed = 100;
Don't actually use speed as a variable as it is a pre-builtin variable in game maker. Instead make one up like velocity & maxvelocity (vel and max vel).

Then in the step event you need to establish your controls (which I assume you already have; the following is just for example) and movement.

Code:
key_right = keyboard_check(vk_right);
key_fly = keyboard_check(vk_up);
key_land = keyboard_check(vk_down);

if speed > maxspeed
    {
    speed = maxspeed
    }

if speed < 0
    {
    speed = 0
    }

if key_right
    {
    speed += .3
    }

if key_left
    {
    speed -= .1
    }
    
if key_fly & speed >= 30
    {
    x -= 1
    }

if key_land
     {
     x += 1
     }
So the above code will move you .3 of a unit right when right direction is pressed and .1 of a unit left if left direction is pressed (to simulate slower deceleration if you want that). The next part (if key_fly & speed >= 30) only allows you to go up if you press up and only if your speed is 30 or greater. Now all of these numbers were chosen basically at random by me so you are gonna want to change them to suite your game. If you wanted your plane to slowly descend automatically when moving too slow add the following in the step event.

Code:
if speed <= 29
     {
     x +=1
     }
I'm sure there are more efficient ways of doing this and you would, again, need to change my numbers around this will for sure not let you fly upwards unless you hit a certain speed. I am a very hands on learner and would need to play around with it way more to get it perfect.
 
Top