Physics engine inconsistent

I have a game where a linearImpulse is performed on an object each ‘round’. The parameters that define the force on the object do not necessarily have to change each round. What I would *expect* to happen is that given the exact same parameters, the object would end up in the exact same position after coming to rest. However, I am seeing an odd ‘cycling’ effect to the final rest position.

Here is the code where I define the physics body:

[lua] local function resetAndAddPlate()

if (plate ~= nil) then
print("Ending Plate Position- " … plate.x … “:” … plate.y)
plate:removeSelf()
end

plate = display.newImageRect( “plateOne.png”, 106, 48)
plate.x = 160
plate.y = 351

physics.addBody( plate, { density=.1, friction=1, bounce=0.2 } )
end[/lua]

Here is where I apply the linearImpulse:

[lua] local xPoint = plate.width * (bombPositionSlider.value/100) - (plate.width/2) + plate.x
local yPoint = plate.y + (plate.height/2)
local power = -100 * (bombAmountSlider.value/100)
print("PreLaunch Plate Position- " … plate.x … “:” … plate.y)
print("Impulse Parameters – power: " … power … ", xPoint: " … xPoint … ", yPoint: " … yPoint )
plate:applyLinearImpulse( 0, power, xPoint, yPoint)[/lua]
The flow of the code is that the resetAndAddPlate function is called to add the ‘plate’ body. A few seconds later (after the ‘plate’ object has time to come to rest) the impulse is applied. The resetAndAddPlate function is not called again until the plate object once again comes to rest.

Here is the output of 6 rounds:

[text]
PreLaunch Plate Position- 160:351
Impulse Parameters – power: -50, xPoint: 160, yPoint: 375
Ending Plate Position- 159.99998474121:351.05023193359

PreLaunch Plate Position- 160.11029052734:351.05023193359
Impulse Parameters – power: -50, xPoint: 160.11029052734, yPoint: 375.050231933
Ending Plate Position- 160.11029052734:351.05023193359

PreLaunch Plate Position- 160.10589599609:351.05023193359
Impulse Parameters – power: -50, xPoint: 160.10589599609, yPoint: 375.050231933
Ending Plate Position- 160.10589599609:351.05075073242

PreLaunch Plate Position- 160.10989379883:351.07263183594
Impulse Parameters – power: -50, xPoint: 160.10989379883, yPoint: 375.072631835
Ending Plate Position- 160.10989379883:351.05200195313

PreLaunch Plate Position- 160.10589599609:351.07577514648
Impulse Parameters – power: -50, xPoint: 160.10589599609, yPoint: 375.075775146
Ending Plate Position- 160.1058807373:351.05380249023

PreLaunch Plate Position- 160.1099395752:351.08773803711
Impulse Parameters – power: -50, xPoint: 160.1099395752, yPoint: 375.0877380371
Ending Plate Position- 160.1099395752:351.05026245117
[/text]

You can see the slight variations of the ending positions. It appears that they are influenced by the slight variations of the PreLaunch position. However, I am running the same code to generate the plate object each round. In this example, the final results are ‘close enough’. However, there are some parameter permutations that result in ending position differences of 100s of pixels.

Is this typical of the physics engine? Is there bound to be some variability between seemingly identical runs? [import]uid: 81026 topic_id: 13459 reply_id: 313459[/import]

I am also seeing inconsistent results with the physics engine.

I ‘launch’ an object and bounce it off various surfaces. The launch paramaters are the same but the path the object takes can be quite different. (Progressively so with the more objects is bounces off, which I guess is to be expected.)

Does anyone know why or at least have a way to try and minimise this please? [import]uid: 51494 topic_id: 13459 reply_id: 53464[/import]