# How do I implement real world physics?

• Hello! Together with my group in a communications/IT class I'm trying to create a real world physics-based catapult-ish game.

The intended purpose is that a user can plot in one or several information pieces into the game, and on beforehand calculate what given starting velocity, angle, etc. would make them hit an intended target. It's for learning physics, for those who have a hard time doing it without a visualization.

My question is: How do I know in what units Construct 2 operates in? The default world gravity seems to be 10, but it should be 9,82 m/s^2, how do I do that for instance?

• Having worked with C2 physics quite a bit I can tell you it is not going to provide real world physics but is designed for games to give the illusion of physics.

Many factors in the real world simply can't be factored in to computed physics that happens in real time because a computer does not react in real time and is a string of events played in order one after the other. It does it super fast but will never match what happens in real life physics.

That being said, you can get some good simulations for studying the effects and teaching basic physics in C2 and you can look at Chipmunk physics by R0J0hound that allows more settings for parameters.

I believe the 10 mark used on C2 is set to actual gravity but the units used are designed to be easier to implement.

There is a catapult example included in C2 and many good discussions on physics in the forum and tutorials to search that should help.

• Having worked with C2 physics quite a bit I can tell you it is not going to provide real world physics but is designed for games to give the illusion of physics.

Many factors in the real world simply can't be factored in to computed physics that happens in real time because a computer does not react in real time and is a string of events played in order one after the other. It does it super fast but will never match what happens in real life physics.

That being said, you can get some good simulations for studying the effects and teaching basic physics in C2 and you can look at Chipmunk physics by R0J0hound that allows more settings for parameters.

I believe the 10 mark used on C2 is set to actual gravity but the units used are designed to be easier to implement.

There is a catapult example included in C2 and many good discussions on physics in the forum and tutorials to search that should help.

Thank you very much, I'll go and check it out!

• I did a breakdown of the units of the physics behavior here:

Basically the units that the physics library that C2 uses is based on SI units. This is the ratio of pixels to meters:

50 pixels : 1 m

But when you set the gravity that's in m/s^2 so you can just set it to 9.8.

• ## Try Construct 3

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

Construct 3 users don't see these ads
• I did a breakdown of the units of the physics behavior here:

Basically the units that the physics library that C2 uses is based on SI units. This is the ratio of pixels to meters:

50 pixels : 1 m

But when you set the gravity that's in m/s^2 so you can just set it to 9.8.

Wow! Cheers mate! That is awesome, thank you very much. I was just sitting and trying to calculate a coefficient when 100 pixels would equal to 1 meter. Thanks a bunch again!

• Great work yet again by Rojo.

### I was about to say something useless like "Open C2 and throw your computer out the window" or something.

• Hello, sorry to revive the thread. But I've encountered a new problem. How do I calculate (or see) the mass of an object? Is it just be the regular Density * Volume, but the volume divided by 50, since that would be outputted into meters?

Oh, and how would I be able to convert a force (newton) into velocity (m/s)?

*edit*

Now that I've looked through my formulars, I see that the gravity acceleration is given by 9,82 N/kg but also in m/s^2 (edit OOPS. m/s^2 not m/s, so I still don't really know what to do. I'm not a master at physics unfortunately :/), meaning F/m would be the same as velocity?

Wrong ->

### Example: F = 10 N m = 0,4045 kg v = 10 / 0,4045 = 24,722 m/s Would that be correct?

• Dude, that is still heavy stuff for me to find some logic in. I see people play with this as kids with Pacman. So it is time for me to bring things under my words. This an attempt for me to understand, sorry if i am wrong. Here goes nothing.

Physics behavior has an expression 'Mass'.

But, that value needs interpretation, depending on how you gonna use it.

50 pixels = 1 meter, therefor we have a conversion factor of 50 between pixels and meters. The engine is using meters internal, just like the real world.

Mass = Volume * Density.

Volume is in cubic meters. But the shapes in construct are 2D.

So we rather have something like 2DMass : 2Darea * Density, according the manual.

But in really the expression mass returns a value Mass : Area * Density * the usually conversion factor.

Or Mass : Area * Density * 50.

That is a factor 50 off. (area = pixel^2 or 50 * 50) But that does not really matter, because if we would use mass in a calculation, this calculation must end up in pixel units. So we will again use the same conversion factor, so twice, or 50 * 50.

So,

if you want the mass returned by the expression in Box2d units (meters) you divide by 50 (the conversion factor)

If you want the mass returned by the expression in pixel units you multiply by 50 (the conversion factor)

Now lets swipe to Newton.

F = m * a.

Force (kg*meter*sec^2)= Mass * Acceleration.

But we usually need kg*pixel*sec^2 to work with pixels.

To work with pixels, we do the regular conversion. If mass = the value (with no unit assigned) in the expression

F = (m * a) * 50

To have it in the units used by the engine (kg*meter*sec^2) the regular conversion from pixels to meters

F = (m * a) / 50