It seems that postCollision sometimes reports unusually large force. Here is an example of this behaviour:
It’s a simple physics scene with one dynamic box and static walls. Additionally there are two circles that are just buttons that push the box left or right. My code prints the collision forces to the terminal. When I bounce the box around I normally get values between 0.1 - 1.0. But if I slowly slide the box from the lower right corner to the left and over the step the collision force will sometimes be exactly 12 (when the box slides over the step). That feels insane. I think it happens especially if I accelerate a little just before the step. How such a large force is possible and why the force is exactly 12? Any ideas? Here is a working example code:
[code]
local physics = require “physics”
physics.start()
physics.setGravity( 0, 3 )
physics.setScale( 60 )
box = display.newRect(800,600,80,80)
physics.addBody( box )
button1 = display.newCircle(70,710,40)
button2 = display.newCircle(170,710,40)
floor1 = display.newRect(0,748,1024,20); physics.addBody( floor1, “static” )
floor2 = display.newRect(405,720,600,30); physics.addBody( floor2, “static” )
wallLeft = display.newRect(0,0,20,768); physics.addBody( wallLeft, “static” )
wallRight = display.newRect(1004,0,20,768); physics.addBody( wallRight, “static” )
local button1Active = false
local button2Active = false
local function ForceLeft(event)
if event.phase == “began” then
button1Active = true
end
if event.phase == “ended” then
button1Active = false
end
end
local function ForceRight(event)
if event.phase == “began” then
button2Active = true
end
if event.phase == “ended” then
button2Active = false
end
end
local function ForceHandler()
if button1Active == true then
box:applyForce( -1, 0, box.x, box.y )
end
if button2Active == true then
box:applyForce( 1, 0, box.x, box.y )
end
end
local function PostCollision( event )
if (event.force > 0.1) then
print(event.force)
end
end
button1:addEventListener(“touch”, ForceLeft)
button2:addEventListener(“touch”, ForceRight)
box:addEventListener(“postCollision”, PostCollision)
Runtime:addEventListener( “enterFrame”, ForceHandler)
[/code] [import]uid: 13507 topic_id: 9850 reply_id: 309850[/import]