Assertion failed crash error...anybody know what this could be?

Assertion failed: (0 <= index && index < m_count), function GetVertex, file /Users/ansca/.hudson/jobs/Main-DMG/workspace/platform/mac/build/Release/Box2D.framework/Headers/Collision/b2Distance.h, line 107.
/Applications/Corona.268/Corona Terminal: line 9: 3839 Abort trap “$path/Corona Simulator.app/Contents/MacOS/Corona Simulator” $*
[import]uid: 14935 topic_id: 8542 reply_id: 308542[/import]

I got similar error like yours… here is output msg.

Assertion failed: (0 <= proxyId && proxyId < m_nodeCapacity), function GetFatAABB, file /Users/ansca/.hudson/jobs/Main-DMG/workspace/platform/mac/build/Release/Box2D.framework/Headers/Collision/b2DynamicTree.h, line 141.
/Applications/CoronaSDK/Corona Terminal: line 9: 15389 Abort trap “$path/Corona Simulator.app/Contents/MacOS/Corona Simulator” $*
logout

Can someone look into this? As for my code, it is fine I think. I can post that too if you guys need more information.

[import]uid: 13978 topic_id: 8542 reply_id: 30640[/import]

would b great if you post some code

c
[import]uid: 24 topic_id: 8542 reply_id: 30741[/import]

Is it possible for me to send you my whole project so you can see it in action? [import]uid: 14935 topic_id: 8542 reply_id: 30746[/import]

i would prefer if you can nail it down otherwise send the whole project but give me specifics on how to make it crash…
c [import]uid: 24 topic_id: 8542 reply_id: 30748[/import]

Here is my code:

[lua] local onCollision = function( self, event )
if event.other.myName == “enemy” and event.target.state == “alive” then
if ( event.phase == “began”) then

–audio.play( crashSound )
local sound_id = mRand(1,2)
if sound_id == 1 and soundOff == false then
audio.play(enemyDeath01)
elseif sound_id == 2 and soundOff == false then
audio.play(enemyDeath01)
end

– add score
setScore(50)

– explosion
local explosion = movieclip.newAnim({“exp01.png”, “exp02.png”, “exp03.png”, “exp04.png”}, 102, 93)
gameGroup:insert(explosion)
explosion.x = event.other.x; explosion.y = event.other.y
explosion:play(4,{ startFrame=1, endFrame=4, loop=1, remove = true })

–event.target:removeEventListener( “collision”, event.target )
event.other.parent:remove( event.other )
event.other = nil
enemyCount = enemyCount - 1

end
elseif event.other.myName == “spike” then
if ( event.phase == “began” ) then
– explosion
local explosion = movieclip.newAnim({“exp01.png”, “exp02.png”, “exp03.png”, “exp04.png”}, 102, 93)
gameGroup:insert(explosion)
explosion.x = event.target.x; explosion.y = event.target.y
explosion:play(4,{ startFrame=1, endFrame=4, loop=1, remove = true })
elseif ( event.phase == “ended” ) then
event.target.state = “dead”
event.target.isVisible = false
event.target.isBodyActive = false
poke_line_y = poke_line_y + 80
ariCount = ariCount - 1
– make gravity stronger :smiley:
ariGravity = ariGravity + 2

–print(“aris " …event.other.id… " is dead!”)
–print("ariCount is: " …ariCount)
–print("aris count is: " …#aris)
end

if ariCount == 0 then
callGameOver()
end
end
end[/lua]

It only happens when main character collides with “spike” and not overtime either. It seems random too. ariGravity is force I use to simulate gravity to push the main character down in the main game loop. Let me know if you need more information.

And the spike is created like this:

[lua] local createSpike = function()
spikes = display.newImageRect( “spikes.png”, 338, 35 )

if system.getInfo(“model”) == “iPad” then
spikes:scale(1.13, 1.13)
end

physics.addBody( spikes, { density=1.0, friction=0.2, bounce=0.1 } )
spikes.bodyType = “static”
spikes.filter = borderCollisionFilter
gameGroup: insert (spikes)
spikes.x = display.contentWidth / 2
spikes.y = 470
spikes.myName = “spike”
end[/lua]

I have tried both on V268 and daily build… same kind of crash. Thanks in advance. [import]uid: 13978 topic_id: 8542 reply_id: 30765[/import]

I think I resolved the crash. I was not removing the body but hiding and disabled it from further physics simulation like so:

event.target.isVisible = false
event.target.isBodyActive = false

I stopped being lazy and actually removed the body and set it to nil and strange crash is gone. Well so far it hasn’t happened.

I will post again if it happens. :smiley: [import]uid: 13978 topic_id: 8542 reply_id: 31025[/import]

Rule: Don’t modify physics properties of bodies inside collision event handlers.

This is very well documented in the forums, but not on the docs (AFAIK) and it catches everyone at least once. Caught me more often than I care to admit.

matt

[EDIT] To modify physics properties/objects in response to collision events, fire a single timer to go off 1 after millisecond and perform the modification in the timer handler. [import]uid: 8271 topic_id: 8542 reply_id: 31077[/import]

I think mine has to do with turning off the physics. [import]uid: 14935 topic_id: 8542 reply_id: 31112[/import]

Yes; Don’t turn off the physics engine and expect physics api calls to work. [import]uid: 8271 topic_id: 8542 reply_id: 31116[/import]