Altitude Calculation

0 favourites
  • 8 posts
  • I'm making a puzzle game where the player manipulates a see-saw to fling an object into a goal.

    I would like to have an on-screen altitude readout showing a constant readout of the object's current altitude.

    How should I write the event to calculate this?

  • are you throwing the object with physics ? If so then I think it would just be a case of

    every tick     text:set text object.Y

    -----

    or are you trying to calculate the position with gravity and mass and velocity... ?

    example

    edit - altered capx so displaying height only while object is moving. (is physics sleeping/else)

  • Create a variable StartY and on start of layout set it to object.y

    Create a variable Altitude and every tick set it to round(abs(object.y-StartY))

    Edit: Removed "de" (stupid swype keyboard!)

  • I will try both those options - thank you very much!

    The calculation just needs to be a simple arbitrary number: X meters off the ground.

  • Create a variable Altitude and every tick set it to round(abs(object.y-StartY))de

    What does the "de" do? Construct 2 is throwing and error when I type that in.

  • Take off the de, I don't think he meant to put that.

  • It was my tablet-keyboard acting funny..

    Sorry..

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • A simpler option without variables might be to just take the Y value of your ground level and set your text to the difference between that and the object's Y value. So just something like Set Text to GroundY - ObjectY. Or if you want it always relative to the catapult, use catapult.Y instead of ground.

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