AirHockey 2: Reordering object placement alters Physics settings?

In the Air Hockey 2 sample game template, I merely switched the order of when the Paddles & Puck are placed in the game with dramatic results.

Bug: The game still functioned, but I was surprised to see a score was recorded for a puck only half way to the goal.

Question: why does it behave this way? Is this behavior a bug using using build 2011.591?

[lua]-- As Downloaded Air Hockey 2 sample Code:
function startGame(event)

titleScreenGroup:removeSelf()

resetScore() – in the case that this is a rematch
– Paddles placed first
placePlayerOnePaddle()
placePlayerTwoPaddle()

– Puck placed Second
placePuck(puckAvalLocation.center)
Runtime:addEventListener( “postCollision”, onPostCollision )
Runtime:addEventListener( “collision”, onCollision )
end[/lua]

[lua]-- Modified ONLY the order of the Puck & Paddle placement function calls in the
– startGame() function.
– Modified code below:
function startGame(event)

titleScreenGroup:removeSelf()

resetScore() – in the case that this is a rematch
– Puck placed first, instead of placePaddles first
placePuck(puckAvalLocation.center)

– Paddles placed Second, instead of Puck placed second
placePlayerOnePaddle()
placePlayerTwoPaddle()
Runtime:addEventListener( “postCollision”, onPostCollision )
Runtime:addEventListener( “collision”, onCollision )
end[/lua]

Switch these 2 sets of function calls (placePuck & placePlayer(One & Two)Paddle) around yourself in the Air Hockey 2 template and give it a try.
http://developer.anscamobile.com/code/air-hockey-2-player-game

Thank you!

-David
[import]uid: 53538 topic_id: 15603 reply_id: 315603[/import]

Can anyone explain this behavior? [import]uid: 53538 topic_id: 15603 reply_id: 57778[/import]

Unfortunetly i dont have time right now to download the template and test out what your saying…

But from looking at what you posted above i will take a wild guess lol.

From the looks of things, the placePlayerOnePaddle() and placePlayerTwoPaddle() functions must create some variables or spawn certain objects that are needed for the placePuck(puckAvalLocation.center) to operate correctly.
By switching them arond, the required variables and objects would not have been created, and therefore unpredictable behaviour may occur by calling the other function first.

I will look into it when i have more time… but for now, look further into those functions and see if they create some variables/objects that are needed in the other functions, and hence why the functions would be called in that order.

If i have completely misread the question, i apologize lol.
[import]uid: 69826 topic_id: 15603 reply_id: 57815[/import]