How to solve collision issue?

Guzzz

  • *
  • Posts: 439
Hi to all!

From time to time I have a crash (or better say freeze) in my game and I think I know why. My character has some shape collisions and they are different depending on the animation. For instance when the player presses block, the animation is switching into another one with different collision forms.  Since I have objects that should bounce from him sometime they stuck inside of the character right at the moment when it's animation was changing. I guess this causes the freeze. Please look at the picture I attached. I need to figure out how to solve this.
Watch my new game http://www.hitandcrash.com based on my comic strip https://www.instagram.com/hitandcrash

HeadlessD is my hand-painted dungeon crawler on iOs. Made in Stencyl. https://itunes.apple.com/app/id1153392110

vicevicebingo

  • Posts: 50
For an actor looks like number 7
stucking in something is interesting.

That isn't rotation?
Isn't that rotating?
Hey that is rotation?

merrak

  • *
  • Posts: 2473
You're probably right--the crash is caused by the collision being unresolvable and the handler throwing a fit about it. I remember having this problem on my second ever Stencyl game--a pinball game, where I would change the collision group on the ball after it exited a ramp. This was a long, long time ago (using Stencyl 2.x).

Unfortunately, my solution wouldn't work for you. I just adjusted the ramp exit point so that the ball couldn't exit inside one of the solids below the ramp.

I don't know if Box2D has some kind of trick you can use to detect this issue. I wrote my own physics engine and it freaks out when this scenario occurs. So it's not just Box2D... although when my physics engine fails it's quite a bit more spectacular (launching the actor in a random direction at such a speed that they fly through every wall and out of the level)

One thing to check is that you're only using motion blocks to set the actor positions. If that doesn't work, the only other thing I can think of is to check if the ball is in the "danger zone" before changing the animation. If we're talking only a frame or two, you could delay the animation change just long to let the ball move out of the way and the player may not notice.

Guzzz

  • *
  • Posts: 439
I guess I need to enforce or adjust the Continuous Collision, so when such thing happens the objects could push each others somehow... 
The other option could be to check before changing the animation if any object could end up inside of the character, then... push it..? but then just push it isn't enough, the object might be blocked by others so... maybe squeeze it?.. I could also move collisions inside of the character... the best option is still to do something when one collision ended up inside of the other one. Maybe move, squeeze anything, but not to freeze!
Watch my new game http://www.hitandcrash.com based on my comic strip https://www.instagram.com/hitandcrash

HeadlessD is my hand-painted dungeon crawler on iOs. Made in Stencyl. https://itunes.apple.com/app/id1153392110

merrak

  • *
  • Posts: 2473
As long as you're using the motion blocks to move actors, you shouldn't have a problem with freezing. Setting the actor position, changing collision box sizes, etc., override the physics model. So imagine you take control of your modeled world, fiddle with it, then hand it back to the physics engine, "here you go." Most of the time it can figure out what you did, but this time it can't.

I think your best bet will be the latter you mentioned--check before changing the animation then push the object out of the way. Not sure what the best way to go about that is.

Keep in mind I could be totally off on all of this, and the problem is something else. The last time I ran into this problem was using Stencyl 2.2 and a lot has changed since then. If it were me, I'd use a debugger to check where the crash is occurring before investing any time in trying to solve this problem.

Guzzz

  • *
  • Posts: 439
What do you mean by using debugger?
Watch my new game http://www.hitandcrash.com based on my comic strip https://www.instagram.com/hitandcrash

HeadlessD is my hand-painted dungeon crawler on iOs. Made in Stencyl. https://itunes.apple.com/app/id1153392110

merrak

  • *
  • Posts: 2473
What do you mean by using debugger?

Like GDB. Run the program with the debugger and when it crashes, read the backtrace. What I'd expect to see if we're both right is that some function gets called over and over, running in a loop that doesn't break.

Guzzz

  • *
  • Posts: 439
Ohh I see. I need to try to get this bug happened on Flash and see what Stencyl's Log Viewer would say. But I'm pretty sure it's not my code that got stuck, it's something with collision. This image I posted looks very weird if you know the game. Objects couldn't possibly go that deep of other objects. The problem with this situation I suppose is this object hasn't been pushed enough by Continues Collision mechanism because this object has been pushed also from outside (from the left). So at the end Continues Collision pushes to the left from where this object is coming from and other force (I have strong wind in the game at this moment) is pushing it to the right... so here is a conflict.
Watch my new game http://www.hitandcrash.com based on my comic strip https://www.instagram.com/hitandcrash

HeadlessD is my hand-painted dungeon crawler on iOs. Made in Stencyl. https://itunes.apple.com/app/id1153392110