Hi! Is there physics speed limitation in Corona? If yes, how can i unlock?
Hi @boros.tamaska,
Can you specify what you mean by “physics speed”? Frames per second of the overall app? Sensitivity of velocity and position iterations?
All of the physics APIs are listed here:
http://docs.coronalabs.com/api/library/physics/index.html
Thanks,
Brent
OK, so the maximum physics speed what i can reach is 60 pixel/frame and i cant increase this value. I use applyForce. Vain to increase the value of applyForce, after a certain value of applyForce is doesn’t increase the speed. So, how can I reach the 60+pixel/frame speed?
I captured it: http://www.youtube.com/watch?v=tyPV-jbkrTA&feature=youtu.be
And here is the code:
local group = self.view local background = display.newRect(group, 0, 0, display.contentWidth, display.contentHeight ) background:setFillColor( 128 ) local Text = display.newText(group,"Physics max\n speed test", 0, 0, native.systemFont, 40) Text.x,Text.y=display.contentCenterX ,50 local Camera=display.newGroup() group:insert(Camera) local crate = display.newImageRect(Camera, "crate.png", 90, 90 ) crate.x, crate.y, crate.rotation = 160, -100, 15 physics.addBody( crate, { density=1.0, friction=0.3, bounce=0.3 } ) local grass = display.newImageRect(Camera, "grass.png", screenW, 82 ) grass:setReferencePoint( display.BottomLeftReferencePoint ) grass.x, grass.y=0, display.contentHeight physics.addBody( grass, "static", { friction=0.3 } ) local grass2 = display.newImageRect(Camera, "grass.png", screenW, 82 ) grass2:setReferencePoint( display.BottomLeftReferencePoint ) grass2.x, grass2.y=400, display.contentHeight+800 physics.addBody( grass2, "static", { friction=0.3 } ) local x,y=crate.x,crate.y ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Runtime:addEventListener("enterFrame",function() crate:applyForce( 500, 2000, crate.x, crate.y ) Camera.x,Camera.y=-crate.x+150,-crate.y+300 local D\_x=x-crate.x local D\_y=y-crate.y local Dist=math.sqrt( D\_x\*D\_x + D\_y\*D\_y ) print("Speed: ",Dist) x,y=crate.x,crate.y end) ------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Hi Boros,
It’s correct that you can only apply more force 60 times per second (and of course, you must have your app configured to run at that speed, versus the default 30 FPS). However, the application of force is rather “sensitive” and with the values you’re giving the API, this should send the crate flying off the screen very fast. Thus, I think there’s something not quite proper in your method.
It looks like you’re getting the same result from your output of the Pythagorean theorem because you’re resetting “x” and “y” to the crate’s x and y on each increment of the Runtime. So, it’s just doing the same calculation over and over… but this isn’t reflecting the actual speed of the crate in regards to force.
You can check the velocity of a physics object by this:
[lua]
local vx, vy = myBody:getLinearVelocity()
[/lua]
Brent
I do not reset anything, but look now i dont use the Pythagorean theorem and the applyForce, just the gravity pull down the crate. And what happens? It is stoped at 1800 pixel/sec that is 60 pixel/frame, but why stoped why not accelerate further? Is there a physics speed limitation? How can i unlock the limit?
Video:
http://www.youtube.com/watch?v=nchtOWQaZI0&feature=youtu.be
script:
local group = self.view local background = display.newRect(group, 0, 0, display.contentWidth, display.contentHeight ) background:setFillColor( 128 ) local Text = display.newText(group,"Physics max\n speed test", 0, 0, native.systemFont, 40) Text.x,Text.y=display.contentCenterX ,50 local Camera=display.newGroup() group:insert(Camera) local crate = display.newImageRect(Camera, "crate.png", 90, 90 ) crate.x, crate.y, crate.rotation = 160, -100, 15 physics.addBody( crate, { density=1.0, friction=0.3, bounce=0.3 } ) local grass = display.newImageRect(Camera, "grass.png", screenW, 82 ) grass:setReferencePoint( display.BottomLeftReferencePoint ) grass.x, grass.y=0, display.contentHeight physics.addBody( grass, "static", { friction=0.3 } ) local grass2 = display.newImageRect(Camera, "grass.png", screenW, 82 ) grass2:setReferencePoint( display.BottomLeftReferencePoint ) grass2.x, grass2.y=400, display.contentHeight+800 physics.addBody( grass2, "static", { friction=0.3 } ) ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Runtime:addEventListener("enterFrame",function() Camera.x,Camera.y=-crate.x+150,-crate.y+300 print("Speed: ",crate:getLinearVelocity()) end) ------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Hi @boros.tamaska,
Can you specify what you mean by “physics speed”? Frames per second of the overall app? Sensitivity of velocity and position iterations?
All of the physics APIs are listed here:
http://docs.coronalabs.com/api/library/physics/index.html
Thanks,
Brent
OK, so the maximum physics speed what i can reach is 60 pixel/frame and i cant increase this value. I use applyForce. Vain to increase the value of applyForce, after a certain value of applyForce is doesn’t increase the speed. So, how can I reach the 60+pixel/frame speed?
I captured it: http://www.youtube.com/watch?v=tyPV-jbkrTA&feature=youtu.be
And here is the code:
local group = self.view local background = display.newRect(group, 0, 0, display.contentWidth, display.contentHeight ) background:setFillColor( 128 ) local Text = display.newText(group,"Physics max\n speed test", 0, 0, native.systemFont, 40) Text.x,Text.y=display.contentCenterX ,50 local Camera=display.newGroup() group:insert(Camera) local crate = display.newImageRect(Camera, "crate.png", 90, 90 ) crate.x, crate.y, crate.rotation = 160, -100, 15 physics.addBody( crate, { density=1.0, friction=0.3, bounce=0.3 } ) local grass = display.newImageRect(Camera, "grass.png", screenW, 82 ) grass:setReferencePoint( display.BottomLeftReferencePoint ) grass.x, grass.y=0, display.contentHeight physics.addBody( grass, "static", { friction=0.3 } ) local grass2 = display.newImageRect(Camera, "grass.png", screenW, 82 ) grass2:setReferencePoint( display.BottomLeftReferencePoint ) grass2.x, grass2.y=400, display.contentHeight+800 physics.addBody( grass2, "static", { friction=0.3 } ) local x,y=crate.x,crate.y ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Runtime:addEventListener("enterFrame",function() crate:applyForce( 500, 2000, crate.x, crate.y ) Camera.x,Camera.y=-crate.x+150,-crate.y+300 local D\_x=x-crate.x local D\_y=y-crate.y local Dist=math.sqrt( D\_x\*D\_x + D\_y\*D\_y ) print("Speed: ",Dist) x,y=crate.x,crate.y end) ------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Hi Boros,
It’s correct that you can only apply more force 60 times per second (and of course, you must have your app configured to run at that speed, versus the default 30 FPS). However, the application of force is rather “sensitive” and with the values you’re giving the API, this should send the crate flying off the screen very fast. Thus, I think there’s something not quite proper in your method.
It looks like you’re getting the same result from your output of the Pythagorean theorem because you’re resetting “x” and “y” to the crate’s x and y on each increment of the Runtime. So, it’s just doing the same calculation over and over… but this isn’t reflecting the actual speed of the crate in regards to force.
You can check the velocity of a physics object by this:
[lua]
local vx, vy = myBody:getLinearVelocity()
[/lua]
Brent
I do not reset anything, but look now i dont use the Pythagorean theorem and the applyForce, just the gravity pull down the crate. And what happens? It is stoped at 1800 pixel/sec that is 60 pixel/frame, but why stoped why not accelerate further? Is there a physics speed limitation? How can i unlock the limit?
Video:
http://www.youtube.com/watch?v=nchtOWQaZI0&feature=youtu.be
script:
local group = self.view local background = display.newRect(group, 0, 0, display.contentWidth, display.contentHeight ) background:setFillColor( 128 ) local Text = display.newText(group,"Physics max\n speed test", 0, 0, native.systemFont, 40) Text.x,Text.y=display.contentCenterX ,50 local Camera=display.newGroup() group:insert(Camera) local crate = display.newImageRect(Camera, "crate.png", 90, 90 ) crate.x, crate.y, crate.rotation = 160, -100, 15 physics.addBody( crate, { density=1.0, friction=0.3, bounce=0.3 } ) local grass = display.newImageRect(Camera, "grass.png", screenW, 82 ) grass:setReferencePoint( display.BottomLeftReferencePoint ) grass.x, grass.y=0, display.contentHeight physics.addBody( grass, "static", { friction=0.3 } ) local grass2 = display.newImageRect(Camera, "grass.png", screenW, 82 ) grass2:setReferencePoint( display.BottomLeftReferencePoint ) grass2.x, grass2.y=400, display.contentHeight+800 physics.addBody( grass2, "static", { friction=0.3 } ) ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Runtime:addEventListener("enterFrame",function() Camera.x,Camera.y=-crate.x+150,-crate.y+300 print("Speed: ",crate:getLinearVelocity()) end) ------------------------------------------------------------------------------ ------------------------------------------------------------------------------
An answer ?
the limit is built into box2d. usually only a “problem” if the scale of your objects (in pixels) doesn’t adequately match box2d’s scale (which converts pixels to meters). the OP’s example was capped at 60px, so we can assume he was using the default scale of 30, because it correlates with box2d’s limit of 2 units per time step. but probably wasn’t appropriate because that’d make his 90px crate 3m in dimension - which seems like a pretty huge crate. instead change to physics.setScale(60) (or even 90, if OP’s crate intended to be about a meter in simulated size) and you’d cap out at 120 (or 180), which is pretty dang fast in real-world units for a falling crate! (consider: even at the default scale 30, OP’s crate was moving at 60px/30ppm*60fps = 120m/s, or about 268mph – so it was ALREADY a pretty fast-moving crate!!) hth
An answer ?
the limit is built into box2d. usually only a “problem” if the scale of your objects (in pixels) doesn’t adequately match box2d’s scale (which converts pixels to meters). the OP’s example was capped at 60px, so we can assume he was using the default scale of 30, because it correlates with box2d’s limit of 2 units per time step. but probably wasn’t appropriate because that’d make his 90px crate 3m in dimension - which seems like a pretty huge crate. instead change to physics.setScale(60) (or even 90, if OP’s crate intended to be about a meter in simulated size) and you’d cap out at 120 (or 180), which is pretty dang fast in real-world units for a falling crate! (consider: even at the default scale 30, OP’s crate was moving at 60px/30ppm*60fps = 120m/s, or about 268mph – so it was ALREADY a pretty fast-moving crate!!) hth