How do I do an flying physic like in "learn to fly"?

0 favourites
  • 5 posts
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • Hello, I'm new to construct 3 and coding in general.

    I would like to make a game where the main gameplay is gliding through the sky but I can't manage to do a good and fluid physic like.

    The result I search is when your glider is at enough speed it goes up depending on the angle he is.

    I already try to add force or velocity when I reach the speed, but the result is not great.

    Here's the c3p file: gofile.io/d/okz6en

    If someone can explain in a simple way to me how I can achieve a great physic that would be great.

    I already watched some YouTube videos where people explain how flies physic work in the real world, but I don't see how I can put it in construct.

    Thanks

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Here’s a rough way to do lift. Basically you find the velocity perpendicular to the wing with a dot product and apply a force from that to do lift. It’s modeled after a lift formula found on Wikipedia. You’d tune it by adjusting the lift variable.

    Var vrel=0
    Var lift = 0.01
    
    Every tick
    — set vrel to sprite.physics.velocityX*cos(sprite.angle +90) + sprite.physics.velocityY*sin(sprite.angle +90)
    — sprite: apply force -sign(vrel)*lift*vrel*vrel at angle sprite.angle+90

    Drag can be done similarly but with sprite.angle instead of sprite.angle+90, and it would have its own drag variable to tune instead of lift.

    It can probably be modeled better by scaling the lift by the width of the wing and scaling the drag by the wings height. But that would require tuning the scaling variables more. It probably could give pretty convincing motion with a wing a tail and a prop to give thrust.

    There are probably many other improvements to make the model better

  • Wow, thanks you so much.

    It works really well, way more than what I was trying.

    Since I'm bad with maths I will try to understand the code, because right now I understand just a bit of it.

    If you have any tips on how to make physics even better, please don't hesitate, I'm all ears.

  • R0J0hound

    I have a little problem. I wanted the player to fall when it close the glidder but when the lift is over 0.2 the glidder and the player is stuck middle air. I think is the lift that do that but I can manage to correct this bug. Do you have an idea what I can do ?

  • R0J0hound

    I didn't manage to patch the bug. It occur when the objet touch another one with physic. I don't know why but the velocity switching between positive and negative value and i don't konw why. Here the file if you can help me gofile.io/d/4hgMbO.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)