Strange behavior regarding collisions...

I’m new here and I’ve been working like crazy this past week converting over one of my existing games to Corona. Once I have successfully ported it over (which should be well before my 30-day trial expires), I’ll be purchasing a year subscription… so thank you Ansca for Corona, it is by far the BEST iPhone development tool I’ve used.

First of all, I understand Game Edition is in Alpha state, so if any of the strange behaviors I describe aren’t fixable, then I guess this can be taken as a bug report.

Before I go into the details of my problem, here is some background information on my project…

First, it might help to know that I’m using the physics engine for only two purposes at the moment: spritesheets and collision detection. I read somewhere that the latest version of Box2D allows for collision detection among NON-physical objects and that Corona was going to implement that but I can’t find anything on it, and I can’t get anything to collide UNLESS I .addBody().

Since that’s very little to be using the physics engine for, I tried using a Box2Box collision function I found here on the forums for manual collision detection, but it slowed my game down so much it was unbelievable (the accelerometer wouldn’t even work, which is how the main player object is controlled).

I have my own movement code that worked well for me apart from the physics engine, so I decided to set gravity to (0, 0) so I can move X and Y attributes freely. All I need is very simple collision detection so I have all my objects density, friction, and bounce set to ZERO.

All of the game objects are continuously moving UP (y - gameSpeed) during the main–and only–enterEvent “loop” with the main player object staying at a fixed Y position to simulate downward movement.

The problem, or strange behavior, is that sometimes the objects that are moving up get “stuck” before they collide with the player and even the sensor. It’s like a big invisible box is drawn around the objects and sometimes they get stuck there until another object pushes it upward from the bottom and gives it a “boost” at which point the stuck object will continue on it’s original path.

It doesn’t do that all the time though, in fact, most of the time everything works fine. When objects collide with the main player object they removeSelf() and do what they’re supposed to do, but every now and then they get stuck probably about 10-15 pixels below the main player objects and just float there (and sometimes the sensor object which is placed above the screen in the negative Y space).

I tried playing around with all the density, friction, etc. and even tried changing up body types and no matter what combination I come up with, the same problem persists… so I’m thinking it might just be a bug.

It would make my life 1000X easier if I could just have NON-physical objects collide (just checking to see if the display objects touch). Once again I thought I read somewhere that this was going to be possible in Alpha 2 but I may be mistaken… any light Ansca could shed on that would be greatly appreciated.

Anyway, sorry for the long-winded post… I’m extremely happy with Corona and if I could get these minute little “annoyances” taken care of my game will be well on it’s way to be ready for completion.

Please help, thank you very much…

Jonathan Beebe [import]uid: 7849 topic_id: 1533 reply_id: 301533[/import]

Anyone?

If nobody has anything to say, could someone at least tell me if it’s possible to detect collisions (with Box2D) among NON physical objects using Corona?

I’m pretty sure I read one of the Ansca admins talk about that before on a previous forum post, so could any Ansca staff shed some light on that question?

I would greatly appreciate it, thank you very much :slight_smile: [import]uid: 7849 topic_id: 1533 reply_id: 4356[/import]

I guess nobody knows? What about anyone from Ansca? (at least in regards to my second post above) [import]uid: 7849 topic_id: 1533 reply_id: 4380[/import]

Hi, Jonathan. Corona does not currently support collision detection in non-physical objects.

You are correct that the version of Box2D we use does have a feature like that, but I believe that mode supports point-to-shape collision testing only, not shape-to-shape, so it’s not as generally useful as the physical collision testing, and I don’t think it would help in your case. But either way, we don’t expose this in the current alphas.

We have had previous requests for lightweight display object collision detection that didn’t engage the full physics model, and I agree that would be useful. But I’m not sure that Box2D is the best way to get to that.
[import]uid: 3007 topic_id: 1533 reply_id: 4444[/import]

Oh – and we should also check to see whether you’ve found a bug, because the behavior you describe does sound odd. Can you zip your project folder and send it to beta@anscamobile.com?

As a first guess, are you testing for a specific collision phase when you detect collisions? The current collision code reports a LOT of data, including a “preSolve” phase that may fire one or more times BEFORE the collision happens. If you don’t want that, you should probably test only for event.phase == "began" . [import]uid: 3007 topic_id: 1533 reply_id: 4445[/import]