Jump to content

How can I calculate falling time when effected by gravity?


hlissnake
 Share

Recommended Posts

as we know.  Object veloctiy will be change by acceleration such as gravity

 

and velocity = Acceleration x time, and gravity accelerate constant is 9.81 in our real world.

 

but I don't understand the gravity value in phaser phyics system, 

 

so, can you just show how sould I calculate object move time by the phaser gravity. it is different from real world gravity

Link to comment
Share on other sites

In real life the gravity is 9.81 m/sand that means the velocity will be 9.81 m/s greater every second, in phaser you could say that the gravity is pixels per tick per tick.

To calculate the time that it takes to move from point A to B is quite "hard" in games because the speed is in pixels per tick and the time of 1 tick is variable.

I'm not entirely sure how many ticks per second Phaser but I think it uses 60 ticks per second.

If 1 pixel in your game represents 1 meter then your Y gravity should be 588.6 pixel/second.

 

To calculate the time it takes for an object to fall you have the equation t = sqrt(2 * distance / g) so in this case t (in seconds) = sqrt(2 * distance / 588.6).

Link to comment
Share on other sites

In real life the gravity is 9.81 m/sand that means the velocity will be 9.81 m/s greater every second, in phaser you could say that the gravity is pixels per tick per tick.

To calculate the time that it takes to move from point A to B is quite "hard" in games because the speed is in pixels per tick and the time of 1 tick is variable.

I'm not entirely sure how many ticks per second Phaser but I think it uses 60 ticks per second.

If 1 pixel in your game represents 1 meter then your Y gravity should be 588.6 pixel/second.

 

To calculate the time it takes for an object to fall you have the equation t = sqrt(2 * distance / g) so in this case t (in seconds) = sqrt(2 * distance / 588.6).

thank you. finally I use body.accelerate.y to instead of Gravity in game. 

the speed is not like you say per pixies per tick.  in phaser it's show as the velocity per second, and that may be nearly 60 tick in each second, not excatlty. but allmost.  so we must use velocity multiply tick time to get the translate in this tick.

 

gravity value in phaser is not clear to understand.  eg:   I use velocity.y = 1800 to emulate gravity 30.  when object jumping in air. I gave it -600 velocity above. and the falling effect is almost prefect

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...