Possible collision bug

docskull

  • Posts: 65
Hello there, I have run into a problem that might be a bug, so I would be greatly thankful if someone could help with this.

I am building a game with a flying character and enemies that chase him and then shoot him. All works fine except that the game completely freezes and flash eventually spits errors when:

-The collision bounding boxes of two actors overlap, then a third actor (in this case a bullet) collides with this "overlapping areas". A screenshot follows, showing where the missile (the little axe) collides with the overlapping areas on collision boxes.

As far as I know, the collision bounding boxes should not even ever overlap, right? I made some more extensive testing along the last few days and without the "third actor collision" (turning off  the shoot bullets behavior) there is no bug.

I have attached both the screenshot and logs and here goes the errors that flash spits out when it eventually crashes:

[object AlchemyExit]
   at Function/<anonymous>()
   at Function/<anonymous>()
   at Box2DAS.Dynamics::b2Body/SetTransform()[/Users/jon/Desktop/stencyl/plaf/flash/Box2DAS/Box2DAS/Dynamics/b2Body.as:150]
   at Box2DAS.Dynamics::b2Body/SetAngle()[/Users/jon/Desktop/stencyl/plaf/flash/Box2DAS/Box2DAS/Dynamics/b2Body.as:140]
   at stencyl.api.engine.actor::Actor/setAngle()[/Users/jon/Desktop/stencyl/plaf/flash/root/stencyl/api/engine/actor/Actor.as:1780]
   at scripts::Design_20_20_AIGotoactor/update()[C:\Users\guilherme.nunes\stencylworks\preview\scripts\Design_20_20_AIGotoactor.as:58]
   at stencyl.api.engine.behavior::Behavior/update()[/Users/jon/Desktop/stencyl/plaf/flash/root/stencyl/api/engine/behavior/Behavior.as:203]
   at stencyl.api.engine.behavior::BehaviorManager/update()[/Users/jon/Desktop/stencyl/plaf/flash/root/stencyl/api/engine/behavior/BehaviorManager.as:123]
   at stencyl.api.engine.actor::Actor/innerUpdate()[/Users/jon/Desktop/stencyl/plaf/flash/root/stencyl/api/engine/actor/Actor.as:743]
   at stencyl.api.engine::GameState/innerUpdate()[/Users/jon/Desktop/stencyl/plaf/flash/root/stencyl/api/engine/GameState.as:1517]
   at stencyl.api.engine::GameState/postUpdate()[/Users/jon/Desktop/stencyl/plaf/flash/root/stencyl/api/engine/GameState.as:1395]
   at stencyl.api.engine::GameState/update()[/Users/jon/Desktop/stencyl/plaf/flash/root/stencyl/api/engine/GameState.as:1377]
   at org.flixel::FlxGame/update()[/Users/jon/Desktop/stencyl/plaf/flash/flixel/org/flixel/FlxGame.as:400]

Alexin

  • *
  • Posts: 3132
It's a Box2D problem. Sometimes it crashes when two or more objects collides/overlap with no room to spare. I don't know any solution to this problem.
"Find the fun"
alexin@stencyl.com

docskull

  • Posts: 65
Thanks very much anyway Alexin!

I was crazy thinking it might be something I did. Now I can plan a workaround if there's no solution. Helped a lot cause now I can plan an alternative for this situation not to happen

(Maybe not rotating the actor, but creating multiple animations for simulating facing, this way overlaps will rarely happen given collision boxes wont rotate their corners)

Giving it a shot soon, thank you

docskull

  • Posts: 65
I have found a way around, for my game at least:

My bug was being caused when the "bullets" overlapped a collision area, as in the screenshot  I linked above. I have rebuilt my "missile fire" to fire missiles based on "tweens" so part of the physics for the bullets was disabled.

The bullets now work a different way, I am rebuiliding their logic, but the game never had the same crash in various tests so far.

(This might not solve the problem for everyone, but it is a way around for some people)

Jon

  • *
  • Posts: 17524
Are you guys purely using physics motions (forces and velocities) to get this to happen? Although I can easily repro it in the examples provided, when I tried to replicate a simple demo on my own and crush an actor or twist it against something else, it wouldn't error out. There must be some other precondition for this to happen.

docskull

  • Posts: 65
Hello Jon,

In my game at least it only bugged when an actor (in my case a bullet fired by an enemy) collided against an "intersection" of two collision boxes. (as in the screenshot)

My game won't be good for you to test anymore cause I changed the bullet movement to tweens.

But maybe using non-physics movment as you said would fix it :P


docskull

  • Posts: 65
Correction, just had the same bug again...

When I pushed an enemy against a scenario prop (the castle) and shot it at the same time, the game crashed as described above.

My game is named dragona and is on my private stencylforge resources, needs me to make it public for you to check the bug?

Alexin

  • *
  • Posts: 3132
Can you reproduce the error consistently? I can't do it on my end and I need a way to reproduce it.
"Find the fun"
alexin@stencyl.com

Jon

  • *
  • Posts: 17524
Alexin discovered the cause, but we have to do some talking with the Box2D devs about an actual fix - it is a bug in Box2D that was fixed a while back, but because of our customizations, it isn't straightforward to fix (we tried and the fix did not work).

Alexin

  • *
  • Posts: 3132
In the meantime, disable Continuous Collision Detection if you run into the issue again and if your game permits it (Gravitas really needs CCD or the gameplay is trashed).
"Find the fun"
alexin@stencyl.com

MerlinoDreamlab

  • *
  • Posts: 20
I have a bad collision bug problem and the game freeze (also browser freeze)...

I put a test game to show this problem: http://www.stencyl.com/game/play/10664 with 3 scene

1) Actor without rotation --> it works
2) Just enable the rotation --> goes below the tiles at start!
3) Enable the rotation but put 2 circle for the collision (right walk) it works better, but if you go fast or try to jump it goes below the tiles... or if you try to go left, right it goes through the terrain and frozes.

I have the iStencyl Pro version with no banner (sponsored game).

What I can do? I need the actor rotate because the game have slopes etc... (Ski Game)

Is there some "magic" formula to put in there? Some tips or working around?
Apps for iOS, Android and Web. Game Art and Music.
The company's mantra is "Passion, Love and Creativity" developing apps that uplift, educate and inspire.

Alexin

  • *
  • Posts: 3132
Can you attach the test game, please, so I can investigate?
"Find the fun"
alexin@stencyl.com

MerlinoDreamlab

  • *
  • Posts: 20
In attach the Test Game.

I started with Run and Gun Example Game and then:

1) Imported Ice Tileset and modified collision on some tiles
2) Create the 3 scenes: SceneNoRotation, SceneRotation, SceneRotation2
3) Add the standard Jumper Actor tp SceneNoRotation
4) Clone the Jumper Actor and add rotation and add to SceneRotation
5) Clone the Jumper Actor and add rotation + modified right walk collision adding two circles and add to SceneRotation2
6) Added buttons to switch scenes.

Thank you
Apps for iOS, Android and Web. Game Art and Music.
The company's mantra is "Passion, Love and Creativity" developing apps that uplift, educate and inspire.