Dear friends,
I'm converting a game from Corona to Gideros and everything has been working fine, except the physics. For this game, it would be very important I could set the right parameters in order to produce the same physics behavior it was in Corona. A minimal difference on the trajectory of objects can make the level not be solvable.
OK, in Corona this game uses:
- content = {width = 320, height = 480, scale = "letterbox", fps = 30}
- physics.start() -- default value (body.isSleepingAllowed = true)
- physics.setScale(100)
- physics.setGravity(0, 9.8) -- default value
- physics.setPositionIterations(8) -- default value
- physics.setVelocityIterations(3) -- default value
- physics.setTimeStep(-1) -- default value (must be 1/30 for this case, right?)
In Gideros this game uses:
- Scalemode = Letterbox, Logical dimensions = 320 x 480 px
- application:setFps(30)
- b2.setScale(100)
- b2.World.new(0, 9.8, true)
- b2.World:step(1/30, 8, 3)
This produces very approximate results, but still not enough to generate a satisfactory equivalence. Is there anything I'm missing?
@atilim, would it be possible to achieve a perfect physics equivalence between Corona and Gideros?
Sorry for my bad English and thanks in advance
Comments
Probably they improved the physics in their SDK and unfortunately my game, that was created using an old build (845), is now facing physics issues with their last build.
The good news is that the results using the last Corona's build looks very similar to the results from Gideros.
So... I think I'll have a tough job ahead by recalibrating everything on all levels, unless I could identify what has changed in Corona regarding their physics.
I am attaching the test samples.
I had already tried those fps settings in Gideros Player. Thanks anyway.
I think that is a Corona/Box2D issue. They upgraded Box2D library to version 2.2.1 after the build 2012.840.
Did you try running the project in a older Corona build? The ball is performing a different trajectory in older builds.
Is there a way to use Box2D 2.2.0 in Gideros?
Thanks
to get the same effect! I believe the scalefactor is applied only to positions, not velocities in Gideros, while it seems to be applied to both in Corona.
so if you are setting velocities and forces you will need to scale between Gideros and Corona.
https://github.com/gideros/gideros
https://www.youtube.com/c/JohnBlackburn1975
https://github.com/gideros/gideros
https://www.youtube.com/c/JohnBlackburn1975
1. getPosition, setPosition, getWorldCenter, getLocalCenter functions
2. queryAABB coordinates
3. rayCast coordinates
4. the applying point of applyForce and applyLinearImpulse
5. coordinates/dimensions of PolygonShape, CircleShape, EdgeShape, ChainShape
6. coordinates of anchor points
7. length/maxLength parameters of joints
And scale factor is not used on velocities, forces, accelerations, gravity etc... Still you need to think in meters while passing these parameters (e.g. 9.8 m/s^2)
https://github.com/gideros/gideros
https://www.youtube.com/c/JohnBlackburn1975
http://www.giderosmobile.com/forum/discussion/comment/13987
Author of Learn Lua for iOS Game Development from Apress ( http://www.apress.com/9781430246626 )
Cool Vizify Profile at https://www.vizify.com/oz-apps